//2nd level, get next element after component, here it fails!!$properties = $component->getElementsByTagName('properties')->item(0);...?>

I realised, that there is a different when using different libxml2 versions on Apache2. This code will fail with libxml2 version 2.6.23 and PHP version 5.2.6--->It works fine with libxml2 version 2.6.32 and PHP version 5.2.6-3ubuntu4.6->...and finally it also works with libxml2 2.7.7 and PHP >= 5.3

So if you bored to search for solutions with DOM like I did, please ensure that your www environment has the correct libxml2 / PHP Version installed on your apache2 server.

$nl = $doc->query('//books'); foreach($nl as $node) { while($book = $doc->getElementsByTagNameContext('book', $node)) {//When you now create new nodes within this loop as child or following-sibling of this node // They show up within this loop}

Problem:You have an XML document that contains filename references to, say, images. Each filename reference is defined by <file>filename.ext</file> tag. You'd like to perform perform additional validation, say, after running the XML document through XSD validation. The additional validation can be any of your choice, in this example, it would be ideal to convert the PHP code to a function. The function would then determine if the images exist and return either an integer value or a boolean.