本文实例讲述了php处理复杂xml数据的方法。分享给大家供大家参考,具体如下:
$xml = <<< XML
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程序设计有所帮助。