Nusoap: XML parsing with namespase error

I am using NuSoap for webservice. In response, I get xml with a 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 take it apart. I used the simplexml_load_string function, but I get a warning and the function returns nothing.

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 anyone knows ..

-itin

+4
source share
2 answers

It looks like you are not accessing XML objects correctly, this function will correctly extract xpath children:

 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); } } 

}

+1
source

SimpleXML cannot parse when an envelope with soap is present.

See below:

PHP - SimpleXML does not return an object

0
source

Source: https://habr.com/ru/post/1410934/


All Articles