欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php處理復(fù)雜xml數(shù)據(jù)示例

 更新時(shí)間:2016年07月11日 15:33:49   作者:dotcoo  
這篇文章主要介紹了php處理復(fù)雜xml數(shù)據(jù)的方法,結(jié)合實(shí)例形式分析了php針對(duì)xml格式數(shù)據(jù)的讀取、載入、遍歷、運(yùn)算等相關(guān)操作技巧,需要的朋友可以參考下

本文實(shí)例講述了php處理復(fù)雜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針對(duì)XML文件操作技巧總結(jié)》、《PHP錯(cuò)誤與異常處理方法總結(jié)》、《php字符串(string)用法總結(jié)》、《PHP數(shù)組(Array)操作技巧大全》、《PHP運(yùn)算與運(yùn)算符用法總結(jié)》、《PHP網(wǎng)絡(luò)編程技巧總結(jié)》、《PHP基本語法入門教程》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門教程》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總

希望本文所述對(duì)大家PHP程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論