PHP traversal parsing XML string method, PHP parsing XML string _php Tutorial

Source: Internet
Author: User
Tags php introduction

PHP traversal parsing XML string method, PHP parsing XML string


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 <<
  
    
    

More interested in PHP related content readers can view the site: "PHP operation tips FOR XML file summary", "PHP date and Time usage summary", " PHP Introduction to Object-oriented programming, "PHP array" Operation tips, "PHP string Usage Summary", "Php+mysql Database Operations Primer" and "PHP Common Database Operations Tips Summary"

I hope this article is helpful to you in PHP programming.

http://www.bkjia.com/phpjc/1123807.html www.bkjia.com true Span id= "Isbasedonurl" itemprop= "Isbasedonurl" >http://www.bkjia.com/phpjc/1123807.html techarticle php traverse parsing xml string, PHP parse XML string The example in this article describes how PHP iterates through parsing XML strings. Share to everyone for your reference, as follows: Php$conten ...

  • 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.