Php traversal to parse xml strings

Source: Internet
Author: User
Tags xml example
This article mainly introduces php's method of traversing and parsing xml strings. it involves php's skills for reading, traversing, and parsing xml files based on SimpleXMLElement. it is very simple and practical, for more information about how to parse xml strings, see the example in this article. We will share this with you for your reference. The details are as follows:

 
   
      
   
    
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 the like cannot be effectively output, and echo is relatively smooth. // The above xml example can be removed.
 // You can also remove the header and tail. // <
 
  

I hope this article will help you with PHP programming.

For more articles about how php traverses and parses xml strings, refer to the Chinese PHP website!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.