Re: How to parse this kind of XML

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Feb 7, 2008 6:51 PM, Daniel Brown <parasane@xxxxxxxxx> wrote:

>    I'm sure you're already aware of it, and that it's just a typo in
> the email, but there's a space between the lt carat and the
> event:sessionType node declaration.
>

that screwed me the last time i was posting on a simplexml
namespace issue; silly gmail :D

well, i know there is like nothing that really describes the 3rd and 4th
parameters
on the SimpleXMLElement constructor; or the 2 methods on the
SimpleXMLElement::children() method either, in the manual online.

however, since i just learned about phpt yesterday :), i was able to find a
unit test
distributed w/ php that actually tests said parameters for the
SimpleXMLElement
constructor.
php-5.2.5/ext/simplexml/tests/profile13.phpt

in there youll find this test xml;
$xml =<<<EOF
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
>
<soap:Body>
<businessList foo="bar">
<businessInfo businessKey="bla"/>
</businessList>
</soap:Body>
</soap:Envelope>
EOF;

and then the SimpleXMLElement is constructed via,
$sxe = simplexml_load_string($xml, NULL, 0, 'soap', 1);
removing the namespace declarations in the test xml caused the
test to fail.

you could just str_replace() the first element of the response and
drop a fake namespace in there; its dirty, but it would let you still
use SimpleXML...

-nathan

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux