note 94710 added to simplexmlelement.construct

From: Date: Thu, 19 Nov 2009 18:16:49 +0000
Subject: note 94710 added to simplexmlelement.construct
Groups: php.notes 
Request: Send a blank email to php-notes+get-163093@lists.php.net to get a copy of this message
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); ---- Server IP: 64.71.164.2 Probable Submitter: 64.81.228.176 ---- Manual Page -- http://www.php.net/manual/en/simplexmlelement.construct.php Edit -- https://master.php.net/note/edit/94710 Del: integrated -- https://master.php.net/note/delete/94710/integrated Del: useless -- https://master.php.net/note/delete/94710/useless Del: bad code -- https://master.php.net/note/delete/94710/bad+code Del: spam -- https://master.php.net/note/delete/94710/spam Del: non-english -- https://master.php.net/note/delete/94710/non-english Del: in docs -- https://master.php.net/note/delete/94710/in+docs Del: other reasons-- https://master.php.net/note/delete/94710 Reject -- https://master.php.net/note/reject/94710 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#163093) next »