I am familiar with SimpleXML and am now receiving a SOAP response from a client. I have tried reading as many examples as I can from reading it with SimpleXML, but I just cannot get mine to work! Can some one please show me a line of PHP that reads the DESCRIPTION node in the following code:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetPoliciesResponse xmlns="http://www.abraxas-uk.com/Abraxas/InsuranceWebsite/InsWebService/">
<GetPoliciesResult>
<Policies xmlns="">
<Policy>
<Description>Off-Pad Warranty</Description>
<Plan />
</Policy>
</Policies>
</GetPoliciesResult>
</GetPoliciesResponse>
</soap:Body>
</soap:Envelope>
I am pulling my hair out!
IIRC using SimpleXML with a document containing multiples XML namespaces is a mess.
You could use DOM (ie. without XPath) :
With a more complex case, you may have to use XPath instead of
DOMNode::getElementsByTagName()http://www.php.net/manual/en/class.domxpath.php
For your convenience, you could switch between the two worlds (DOM / Simplexml) :
http://www.php.net/manual/en/function.simplexml-import-dom.php
http://www.php.net/manual/en/function.dom-import-simplexml.php