PHP processing complex XML Data sample code

Source: Internet
Author: User
XML database is a data management system that supports the storage and querying of XML (an application in standard Universal Markup Language) format document. In the system, developers can query, export, and specify the serialization of XML documents in the database.

This article mainly introduced the PHP processing complex XML data method, combined with the instance form analysis PHP for the XML format data reading, loading, traversal, operation and other related operation skills, need friends can refer to the next

<?php$xml = <<< xml<?xml version= "1.0" encoding= "Utf-8"? ><epp xmlns= "Urn:ietf:params:xml:ns: epp-1.0 "xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance "xsi:schemalocation=" Urn:ietf:params:xml:ns: epp-1.0 epp-1.0.xsd "> <response> <result code=" + "> <msg>command completed successfully</ msg> </result> <resData> <domain:chkdata xmlns:domain= "urn:ietf:params:xml:ns:domain-1.0" xsi: schemalocation= "urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd" > <domain:cd> <domain:name avail= "0" & gt;qq.com</domain:name> <domain:reason>domain exists</domain:reason> </domain:cd> <do Main:cd> <domain:name avail= "1" >baidu.com</domain:name> <domain:reason>domain Exists</doma in:reason> </domain:cd> </domain:chkData> </resData> <trID> <cltrid>req-001-0000 000074</cltrid> <svtrid>649334436-1440642163169</svtrid> </trID> </response></epp>XML; $x = simplexml_load_string ($xml); Echo intval ($x- >response->result["Code"]), "\ n"; Echo strval ($x->response->result->msg), "\ n"; $ns = $x->response- >resdata->getnamespaces (true); $cds = $x->response->resdata->children ($ns ["Domain"])->chkdata- >cd;foreach ($cds as $key = $value) {echo intval ($value->name->attributes () ["Avail"]), Strval ($value, Name), Strval ($value->reason), "\ n";}

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.