php處理復雜xml數(shù)據(jù)示例
本文實例講述了php處理復雜xml數(shù)據(jù)的方法。分享給大家供大家參考,具體如下:
<?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="1000"> <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">qq.com</domain:name> <domain:reason>Domain exists</domain:reason> </domain:cd> <domain:cd> <domain:name avail="1">baidu.com</domain:name> <domain:reason>Domain exists</domain:reason> </domain:cd> </domain:chkData> </resData> <trID> <clTRID>REQ-001-0000000074</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"; }
更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《PHP針對XML文件操作技巧總結(jié)》、《PHP錯誤與異常處理方法總結(jié)》、《php字符串(string)用法總結(jié)》、《PHP數(shù)組(Array)操作技巧大全》、《PHP運算與運算符用法總結(jié)》、《PHP網(wǎng)絡(luò)編程技巧總結(jié)》、《PHP基本語法入門教程》、《php面向?qū)ο蟪绦蛟O(shè)計入門教程》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總》
希望本文所述對大家PHP程序設(shè)計有所幫助。
- PHP實現(xiàn)動態(tài)添加XML中數(shù)據(jù)的方法
- PHP解析xml格式數(shù)據(jù)工具類示例
- PHP操作XML作為數(shù)據(jù)庫的類
- PHP中使用xmlreader讀取xml數(shù)據(jù)示例
- PHP生成和獲取XML格式數(shù)據(jù)的方法
- php操作XML、讀取數(shù)據(jù)和寫入數(shù)據(jù)的實現(xiàn)代碼
- php中實現(xiàn)xml與mysql數(shù)據(jù)相互轉(zhuǎn)換的方法
- PHP XML備份Mysql數(shù)據(jù)庫
- php操作xml并將其插入數(shù)據(jù)庫的實現(xiàn)方法
- PHP XML數(shù)據(jù)解析代碼
- PHP實現(xiàn)動態(tài)刪除XML數(shù)據(jù)的方法示例
相關(guān)文章
有關(guān) PHP 和 MySQL 時區(qū)的一點總結(jié)
由于暫時使用國外的空間,在我發(fā)布 Blog 的時候發(fā)現(xiàn)時間總是不對。依據(jù)我以前編寫程序的經(jīng)驗,這是時區(qū)的問題。這個問題解決起來并不難,寫下我的解決途徑以便日后參考。2008-03-03PHP創(chuàng)建XML的方法示例【基于DOMDocument類及SimpleXMLElement類】
這篇文章主要介紹了PHP創(chuàng)建XML的方法,結(jié)合實例形式分析了php基于DOMDocument類及SimpleXMLElement類創(chuàng)建xml文件的具體步驟與相關(guān)實現(xiàn)技巧,需要的朋友可以參考下2019-09-09PHP在不同頁面間傳遞Json數(shù)據(jù)示例代碼
本文為大家介紹下PHP如何在不同頁面間傳遞Json數(shù)據(jù),具體實現(xiàn)如下,感興趣的朋友可以參考下哈,希望對大家有所幫助2013-06-06PHP 命令行工具 shell_exec, exec, passthru, system詳細使用介紹
PHP 為執(zhí)行外部命令提供大量函數(shù),其中包括 shell_exec()、exec()、passthru() 和 system()。這些命令是相似的,但為您運行的外部程序提供不同的界面。2011-09-09Ajax+Jpgraph實現(xiàn)的動態(tài)折線圖功能示例
這篇文章主要介紹了Ajax+Jpgraph實現(xiàn)的動態(tài)折線圖功能,結(jié)合實例形式分析了ajax結(jié)合jpgraph.php類庫繪制動態(tài)折線圖的相關(guān)操作技巧,需要的朋友可以參考下2019-02-02PHP數(shù)組排序函數(shù)合集 以及它們之間的聯(lián)系分析
本篇文章是對PHP數(shù)組排序函數(shù)合集以及它們之間的聯(lián)系進行了詳細的分析介紹,需要的朋友參考下2013-06-06