- simplexml_load_string: documentation ( source)
<?php
$xml = '<?xml version="1.0" encoding="UTF-8"?>
<book>
<section>
<p>Example text</p>
<p>Another text</p>
<img href="imagehref">
<p>Textual content</p>
</section>
</book>';
$xml = simplexml_load_string($xml);
foreach($xml->xpath('/section') as $section) {
echo 'Got section', "\n";
foreach($section->children() as $node) {
echo $node->getName(), "\n";
}
}