Xml solution-php Tutorial

Source: Internet
Author: User
Xml: One of my methods $ api-& gt; responseXML & nbsp; some standard xml files are displayed on the page. how can I decode them as follows: & lt ;? Xml & nbsp; version1.0 & nbsp; encodingUTF-8? & Gt; & lt; S: Envelope & nbsp; xmlns: Swww. w3.org200305soa xml
My method $ api-> responseXML is printed on the page to display some standard xml. how can I decode it?
As follows:




2
98
A http://www.iisp.com/images/v4/logo.gif </imageUri>
Http://www.iisp.com </adLink>



I decode his code as follows.
$ Dom = new DOMDocument ();
$ Dom-> load ($ api-> responseXML); // how to read it
$ Messages = $ dom-> getElementsByTagName ("imagead"); // Picture ad
Foreach ($ messages as $ book ){
// Get id
$ Id = $ book-> getAttribute ('id ');
// Get displayPreference
$ Dis = $ book-> getElementsByTagName ('displaypreference ');
$ DisplayPreference = $ dis-> item (0)-> nodeValue;
// Get preference
$ Pre = $ book-> getElementsByTagName ('preference ');
$ Preference = $ pre-> item (0)-> nodeValue;
// Get imageUri
$ Ima = $ book-> getElementsByTagName ('imageuri ');
$ ImageUri = $ ima-> item (0)-> nodeValue;
// Get adLink
$ Ad = $ book-> getElementsByTagName ('adlink ');
$ AdLink = $ ad-> item (0)-> nodeValue;

// Save data
$ ImageadInfo ['id'] = $ id;
$ ImageadInfo ['displaypreference '] = $ displayPreference;
$ ImageadInfo ['preference '] = $ preference;
$ ImageadInfo ['imageuri '] = $ imageUri;
$ ImageadInfo ['adlink'] = $ adLink;
// Save info
$ ImageadInfos [] = $ imageadInfo;
}
Print_r ($ imageadInfos );

Share To: responseXML? Some standard xml is displayed on the page. how can I decode it as follows:


------ Solution --------------------
What is the problem?
------ Solution --------------------
Yes $ dom-> loadXML ($ api-> responseXML );
Instead of $ dom-> load ($ api-> responseXML );
Because $ api-> responseXML is a string rather than a file name

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.