I know this may be a question for beginners, but please humor me. When reading an xml string with "soap:" in simplexml_load_string () tags will not read in xml.
given this script:
#!/usr/bin/php <?php $s=' <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"> <soap:Header> <context xmlns="urn:zimbra"/> </soap:Header> <soap:Body> <AuthResponse xmlns="urn:zimbraAdmin"> <authToken>somevalue</authToken> <lifetime>123124123</lifetime> <an="zimbraIsDomainAdminAccount">false</a> </AuthResponse> </soap:Body> </soap:Envelope>'; print_r(simplexml_load_string($s)); echo "\n\n"; print_r(simplexml_load_string(str_ireplace("soap:", "", $s))); ?>
I get this output:
jesse@jesse-debian :~/code/zmsoap$ ./xmltest.php SimpleXMLElement Object ( ) SimpleXMLElement Object ( [Header] => SimpleXMLElement Object ( [context] => SimpleXMLElement Object ( ) ) [Body] => SimpleXMLElement Object ( [AuthResponse] => SimpleXMLElement Object ( [authToken] => somevalue [lifetime] => 123124123 [a] => false ) ) ) jesse@jesse-debian :~/code/zmsoap$
I'm just wondering why this is happening, and if there is a better way to fix the problem, rather than replace the string.
source share