Parsing xml, php: php traversal method for parsing xml strings: This article describes how php traverses and parses xml strings. For your reference, see HTTP80index.htm. This article describes how php traverses and parses xml strings. We will share this with you for your reference. The details are as follows:
<? Php $ content = <
HTTP
80
/Index.html
5000
3000
2
3
XML; $ test = new SimpleXMLElement ($ content); // Obtain the ping_protocol value $ ping_protocol = $ test-> global_setting-> ping_protocol; echo "ping_protocol: $ ping_protocol \ n "; // Print the IPforeach ($ test-> instances-> instance as $ instance) {echo "IP: {$ instance ['IP']} \ n";} of all instances ";} // after tests, it is found that the var_dump and other values cannot be effectively output. echo is used smoothly. // The above xml example can be removed. <? Xml version = "1.0" encoding = "UTF-8"?> // You can also remove the header and tail. // <