我有一个soap xml响应,我想要获取leadReferenceNumber节点的值。如何解析SOAP xml以获取某个节点的值
我不知道我是否正确地做了。
这里是我的代码:
$xml = '<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns2:CreateLeadResponse xmlns:ns9="http://www.momentum.co.za/crm/service/type/fault/SystemFault/v1.0" xmlns:ns8="http://www.momentum.co.za/crm/service/type/ProductCategoryType/v1.0" xmlns:ns7="http://www.momentum.co.za/crm/service/type/CampaignType/v1.0" xmlns:ns6="http://www.momentum.co.za/crm/service/type/PreferredContactMethodType/v1.0" xmlns:ns5="http://www.momentum.co.za/crm/service/type/LanguageType/v1.0" xmlns:ns4="http://www.momentum.co.za/crm/service/type/TitleType/v1.0" xmlns:ns3="http://www.momentum.co.za/crm/service/type/application/Lead/v1.0" xmlns:ns2="http://www.momentum.co.za/crm/service/application/CRMLeadService/v1.0"><leadReferenceNumber>LP1391743548576</leadReferenceNumber></ns2:CreateLeadResponse></soapenv:Body></soapenv:Envelope>';
$soap = simplexml_load_string($xml);
$response = $soap->children();
$test = (string)$response->leadReferenceNumber;
echo $test;