- simplexml_load_string: documentation ( source)
<?php
$xml_string = '<?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_string);
foreach($xml->xpath('//section') as $section) {
foreach($section->children() as $node) {
echo $node->getName(), "\n";
}
}