, Php parses xml with namespace

Source: Internet
Author: User
For help, php parses xml with namespace? The xml file is generated by axis: & lt ;? Xml & nbsp; version1.0 & nbsp; encodingUTF-8? & Gt; & lt; soapenv: Envelope & nbsp; xmlns: soapenvschemas. xmlsoap. orgsoapenvelope & nbsp; xml help, php parsing xml with namespace?
The xml file is generated by axis:




{"Code": "2", "message": "The enterprise name matches the enterprise registration number "}





I want to get the content in ns1: checkQyReturn.
How can I obtain it using php?
------ Solution ----------------------
You can use new SimpleXmlElement to solve this problem.


$x = new SimpleXmlElement($str);
foreach($x->entry as $t){
echo $t->id . "
";
echo $t->updated . "
";
$namespaces = $t->getNameSpaces(true);
$gd = $t->children($namespaces['ns1']);
echo $gd->phoneNumber;
}


Reference: http://www.neatstudio.com/show-1549-1.shtml

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.