Personally I'd love to see an option to make it spit out an array. Just like te second parameter in json_decode()
Since array keys can include colons prefix work would also be easier. Then something akin to array2XML() to spit it back out. On Apr 26, 2011, at 7:43 PM, Tom Samplonius <t...@samplonius.org> wrote: > > ----- Original Message ----- > >> A similar problem regarding attributes, that got classified as a doc >> bug, but I >> don't think is one: http://bugs.php.net/42083 > >> If you're fishing around that area of the code, though, perhaps it is >> quite >> obvious to you where/how a patch should be made? > > I would recommend that you re-test that in 5.3.6, as there were a few > changes. I don't know what they were specifically, as I never looked at the > 5.2 SimpleXML code. > > But I also see one issue with your example. > > You look for all child elements in namespace 'http://localhost/a' as follows: > > foreach ($xml->children('http://localhost/a') as $elem) { > unset($elem['attr']); > $elem['attr']="new"; > $elem['attr']="three"; > echo $elem['attr']."\n"; > } > > I would expect the children() method to return just the last two elements of > your input XML: > > <root xmlns="http://localhost/a" xmlns:ns="http://localhost/a"> > <elem attr="abc"/> > <elem ns:attr="abc"/> > <ns:elem attr="abc"/> > <ns:elem ns:attr="abc"/> > </root> > > as the last two elements are the only ones in the 'http://localhost/a' > namespace. > > > But this might be affected by the fact that you specified a namespace on the > constructor. I'm not entirely sure what specifying a namespace on the > constructor does, but I feel it is best avoided (and it isn't described in > the docs). So rather than: > > $xml = simplexml_load_string($str,'SimpleXMLElement',0,'http://localhost/a'); > > just: > > $xml = simplexml_load_string($str); > > > > Tom > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php