Source Code:
(back to article)
<?php //simple xml $xmlData = "<!--?xml version='1.0'?--> <catalog> <language> <name>Php</name> <type>Server Side</type> </language> <language> <name>JavaScript</name> <type>Client Side</type> </language> </catalog>"; //loading the xml string with simplexml function $xml = simplexml_load_string($xmlData); //looping through every node of the molecule foreach ($xml->language as $language) { //node are accessted by -> operator echo $language->name, ' '; echo $language->type, '<br>'; } ?>
Result:
Report an issue