Texts of XML Tags Group in PHP
Suppose now in XML we have several tags:
<root>
<tag>text1</tag>
<tag>text2</tag>
<tag>text3</tag>
</root>
Now the property $xml->tag will
store an iterable object:
<?php
var_dump($xml->tag); // iterable object
?>
Let's iterate over our iterable object with a loop and output the values of our tags:
<?php
foreach ($xml->tag as $tag) {
echo $tag; // 'text1', 'text2', 'text3'
}
?>
Given the following XML:
<root>
<name>john</name>
<name>eric</name>
<name>kyle</name>
</root>
Display each user's name on the screen.