<?php $doc = new DomDocument; // We need to validate our document before referring to the id $doc->validateOnParse = true; $doc->Load('my.xml'); echo $doc->getElementById('php-basics') . " "; ?>