note 89823 rejected from function.simplexml-element-children by danbrown
| From: | danbrown@php.net | Date: | Tue, 24 Mar 2009 21:12:05 +0000 |
| Subject: | note 89823 rejected from function.simplexml-element-children by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-152405@lists.php.net to get a copy of this message | ||
Note Submitter: yours at tdldp dot com
----
Has anybody solved problems loading NS Formatted XML's ???
I've been struggling even with latest php with xml formats like :
<tns:control>
<tns:code_part>01234</tns:code_part>
<tns:code_m>test</tns:code_m>
<tns:type_operation>ident</tns:type_operation>
<tns:num_session>0123456789</siv:num_session>
<tns:date>2001-12-31T12:00:00</siv:date>
</tns:control>
or like :
<tns:test>
<test_Dem xmlns:lns="http://url"
xsi:type="lns:test_Dem" id="id24">
<test_Dem_Cont xmlns:lns="http://url"
xsi:type="lns:test_Dem_Cont" id="id24">
<ID>2</ID>
<test_Cont xmlns:lns="//url" xsd:type="lns:test_Cont"
href="#id25"/>
</test_Dem_Cont>
</test_Dem>
</tns:DA>
<test_Cont xmlns:lns="http://url"
xsi:type="lns:test_Cont" id="id25">
<CI>1122233</CI>
<CI_2>13545646546</CI_2>
</test_Cont>
Those tns semi-colons prevent parsing correctly xml... Only solution found : Replacing XML Source,
by removing semi-colons, before parsing via simple XML...
$data = preg_replace('|<([/\w]+)(:)|m','<$1',$postdata);
$data = preg_replace('|(\w+)(:)(\w+=\")|m','$1$3',$data);
It may help several to find more easily solution to parsing for example soap messages through
SimpleXML (even if and i agree there are soap functions in PHP)