Reputation: 450
I am using NuSoap for webservice. In response i am getting xml with namespace something like :
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none" s:mustUnderstand="1">ABC.CS.Ia.Cts.Ees.Au/IAuth/A</Action>
</s:Header>
<s:Body>
<A xmlns="ABC.CS.Ia.Cts.Ees.Au">
<Au xmlns:d1="ABC.CS.Ia.Cts.Ees.Au" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<d1:Res>Q1</d1:Res>
<d1:n>jFn</d1:n>
</Au>
</A>
</s:Body>
</s:Envelope>
$xml_feed = simplexml_load_string($xmlString);
Now i want to parse it. I have used simplexml_load_string function but getting warning and nothing returned by the function.
Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 7: parser warning : xmlns: URI BC.CS.Ia.Cts.Ees.Au is not absolute in C:\xampp\htdocs\test.php on line 38 Warning: simplexml_load_string() [function.simplexml-load-string]: in C:\xampp\htdocs\test.php on line 38 Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in C:\xampp\htdocs\test.php on line 38
Please help me if any one have know..
-itin
Upvotes: 4
Views: 839
Reputation: 11
Looks like you aren't accessing the XML objects correctly this function will correctly retrieve xpath child items:
function parseSOAPXmlTest($str) {
//parse xml
$xml = simplexml_load_string($str);
echo "xml=" . print_r($xml, true);
if( $xml === false ) { throw new Exception("OBJ is malformed!"); }
foreach($xml->xpath('//s:Header') as $header) {
if( empty($header) ) { throw new Exception("Header is malformed or missing!"); }
echo "header=" . print_r($header, true);
}
foreach($xml->xpath('//s:Body') as $body) {
if( empty($body) ) { throw new Exception("Body is malformed or missing!"); }
echo "body=" . print_r($body, true);
foreach($body->A->Au->xpath('//d1:Res') as $Reschild) {
echo "Reschild=" . print_r($Reschild, true);
}
foreach($body->A->Au->xpath('//d1:n') as $nchild) {
echo "nchild=" . print_r($nchild, true);
}
}
}
Upvotes: 1
Reputation: 31959
SimpleXML can't parse when a soap enveloppe is present.
See below:
PHP - SimpleXML not returning object
Upvotes: 0