An interface to obtain the returned xml file. how to extract useful content

Source: Internet
Author: User
How can I extract useful content from an interface that can get the returned xml file? After the interface is called, $ result = & nbsp; can get the following content: stdClass & nbsp; Object (& nbsp; [out] & nbsp; = & gt; & nbsp; & lt ;? Xml & nbsp; version = "1.0" & nbsp an interface to obtain the returned xml file. how can I extract useful content?
After the interface is called, $ result = can get the following content:

StdClass Object
(
[Out] =>

 
 


?

? T

)

Previously, this directly reads xml, but this kind of Object with stdClass ([out] =>

I don't know how to read the content of each node.

------ Solution --------------------
If you are not familiar with object operations, you can convert them to arrays first, which makes it easier.
The object you get is very simple. $ result-> out is the XML string. if you want to extract the content, you can try string extraction, or parse XML as the object and convert it to an array (recommended ).
http://www.php.net/manual/zh/language.oop5.properties.php


------ Solution --------------------
Print directly
Echo $ result-> out;

Parse as xml
$ Xml = simplexml_load_string ($ result-> out );
Print_r ($ xml );
SimpleXMLElement Object
(
    [flights] => SimpleXMLElement Object
        (
            [flight] => SimpleXMLElement Object
                (
                    [@attributes] => Array
                        (
                            [orgCity] => SHA
                            [departTerm] => T2
                            [dstCity] => CAN
                            [arrivalTerm] => --
                            [airComp] => MU
                            [flightno] => MU5307
                            [planeType] => 320

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.