php处理复杂xml数据示例
2016-08-15来源:

本文实例讲述了php处理复杂xml数据的方法。分享给大家供大家参考,具体如下:

$xml = <<< XML

Command completed successfully

qq.com

Domain exists

baidu.com

Domain exists

REQ-001-0000000074

649334436-1440642163169

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";

}

希望本文所述对大家PHP程序设计有所帮助。

推荐信息
Baidu
map