PHP Parsing XML strings

Source: Internet
Author: User
Tags xml example

<?PHP$content= <<<XML<?xml version= "1.0" encoding= "UTF-8"?> <test> <global_setting> <ping_protocol>http& Lt;/ping_protocol> <ping_port>80</ping_port> &LT;PING_PATH&GT;/INDEX.HTML&LT;/PING_PATH&G          T <response_timeout>5000</response_timeout> XML; $test=NewSimpleXMLElement ($content); //get the value of Ping_protocol$ping _protocol=$test->global_setting->Ping_protocol; Echo"Ping_protocol:$ping _protocol\ n "; //print out IP for all instanceforeach($test->instances->instance as $instance) {      Echo"IP: {$instance[' IP ']} \ n " ; }

//After my test, found that the trial var_dump and the like do not seem to be effective output value, with echo is smooth, there is the above XML example can be removed <?xml version= "1.0" encoding= "UTF-8"?> can also go to the end of the tail//or the <<<xml, and then treated as a normal string, but did not test Chinese and so on

PHP Parsing XML strings

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.