note 94710 deleted from simplexmlelement.construct by danbrown

From: Date: Thu, 19 Nov 2009 18:18:56 +0000
Subject: note 94710 deleted from simplexmlelement.construct by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-163095@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: // 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 (#163095) next »