note 94709 deleted from simplexmlelement.construct by nikic

From: Date: Thu, 24 Oct 2013 16:12:07 +0000
Subject: note 94709 deleted from simplexmlelement.construct by nikic
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-197316@lists.php.net to get a copy of this message
Note Submitter: zwilson at gulosolutions dot com ---- SimpleXML does not correctly parse SOAP XML results if the result comes back with colons ‘:’ in a tag, like <soap:Envelope>. Why? Because SimpleXML treats the colon character ‘:’ as an XML namespace, and places the entire contents of the SOAP XML result inside a namespace within the SimpleXML object. There is no real way to correct this using SimpleXML, but we can alter the raw XML result a little before we send it to SimpleXML to parse. All we have to do is use the preg_replace function to get rid of the colons in the SOAP response tags BEFORE you hand it off to SimpleXML, like so: <?php // SimpleXML seems to have problems with the colon ":" in the <xxx:yyy> response tags, so take them out $xmlString = preg_replace("/(<\/?)(\w+):([^>]*>)/", "$1$2$3", $response); ?>

« previous php.notes (#197316) next »