我想解析一个xml文件,我可以得到d3pp1:key和d3p1:值好的。simplexml卡住解析xml
foreach ($xml_contact->Attributes->KeyValuePairOfstringanyType as $node) {
$key = (string)$node->children('d3p1', TRUE)->key;
$value = (string)$node->children('d3p1', TRUE)->value;
do_stuff($key, $value);
}
,但我也需要得到这个9ccaa69b-fced-e411-80da-00155d0a0806 ,我努力弄清楚如何引用它。
我已经尝试了各种各样的化身沿着这些线路
$node->children('d3p1', TRUE)->value->Id
我在做什么错?
<KeyValuePairOfstringanyType>
<d3p1:key>birthdate</d3p1:key>
<d3p1:value xmlns:d5p1="http://www.w3.org/2001/XMLSchema" i:type="d5p1:dateTime">1940-12-10T11:00:00Z</d3p1:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<d3p1:key>parentcustomerid</d3p1:key>
<d3p1:value i:type="EntityReference">
<Id>9ccaa69b-fced-e411-80da-00155d0a0806</Id>
<KeyAttributes xmlns:d6p1="http://schemas.microsoft.com/xrm/7.1/Contracts"/>
<LogicalName>account</LogicalName>
<Name>Test ABC</Name>
<RowVersion i:nil="true"/>
</d3p1:value>
</KeyValuePairOfstringanyType>
你可能需要做的XML对象的registerXPathNamespace? – RossW
您显示的XML片段有两个根元素。这只是它的一部分或整个事情?如果是整件事情,那是无效的。 – Gordon