有没有一种简单的方法可以使用 SimpleXML xpath 解析标签名称中带有冒号的标签?
例子:
<v12:ProcessShipmentResponse>SUCCESS</v12:ProcessShipmentResponse>
这是我用来解析未命名空间但与命名空间标签中断的标签的代码。
$xml = simplexml_load_string($responseXMLL, NULL, NULL, 'http://schemas.xmlsoap.org/soap/envelope/');
foreach ($xml->xpath('soapenv:Body') as $body) {
$custInfoArr['status'] = (string) $body->v12:ProcessShipmentReply->v12:HighestSeverity;
$custInfoArr['trackingCode'] = (string) $body->v12:ProcessShipmentReply->v12:CompletedShipmentDetail->v12:CompletedPackageDetails->v12:TrackingIds->v12:TrackingNumber;
$custInfoArr['labelCode'] = (string) $body->v12:ProcessShipmentReply->v12:CompletedShipmentDetail->v12:CompletedPackageDetails->v12:Label->v12:Parts->v12:Image;
}