The example in this article describes how PHP iterates through parsing XML strings. Share to everyone for your reference, as follows:
<?php$content = <<
HTTP
/index.html
2
3
XML; $test = new SimpleXMLElement ($content);//Get Ping_protocol value $ping_protocol = $test->global_setting->ping_ Protocol;echo "Ping_protocol: $ping _protocol \ n";//print out all instance Ipforeach ($test->instances->instance as $ Instance) {echo "IP: {$instance [' IP ']} \ n";} Here after testing, found that using var_dump and the like do not seem to be effective output value, with echo more smooth,//And there is the above example of XML can be removed <?xml version= "1.0" encoding= "UTF-8"?>// You can also go to the end of the <<
<>< pre="">
For more information about PHP related content readers can view the topic: "PHP operation tips FOR XML file summary", "PHP date and Time usage summary", "PHP Object-oriented Programming tutorial", "PHP array" operation Skills Daquan, "PHP string ( String) Usage summary, "Getting Started with Php+mysql database operation" and "PHP common database Operation Skills Summary"
I hope this article is helpful to you in PHP programming.
The above describes the PHP traversal parsing XML string method, including parsing xml,php aspects of the content, I hope the PHP tutorial interested in a friend helpful.
<>