wilbcorp
unread,Nov 17, 2009, 1:45:39 PM11/17/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Firebug
using PHP 5.3.0... and FF 3.0.15
echo( $simpleXMLElement->asXML() ) displays incorrectly in the HTML
console display... while the source is correct, the firebug display
has nodes continually further nested in the previous... which is a
shame because it's nice to be able to debug some simple xml
construction w/ firebug. for a test try this...
<?php
$xmlstr = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<!--
TEST XML
-->
<menu></menu>
XML;
$sxe = new SimpleXMLElement($xmlstr);
$sxe->addAttribute('type', 'test3');
$node = $sxe->addchild( 'item' );
$node->addAttribute( 'title', '01' );
$node->addChild( 'sub_1_1' );
$node->addChild( 'sub_1_2' );
$node2 = $sxe->addchild( 'item' );
$node2->addAttribute( 'title', '02' );
$node2->addChild( 'sub_2_1' );
$node2->addChild( 'sub_2_2' );
$node3 = $sxe->addchild( 'item' );
$node3->addAttribute( 'title', '03' );
$node3->addChild( 'sub_3_1' );
$node3->addChild( 'sub_3_2' );
echo $sxe->asXML();
?>
EXPECTED DISPLAY: (but this is what ends up in the source
<menu type="test3">
<item title="01">
<sub_1_1/>
<sub_1_2/>
</item>
<item title="02">
<sub_2_1/>
<sub_2_2/>
</item>
<item title="03">
<sub_3_1/>
<sub_3_2/>
</item>
</menu>
ACTUAL DISPLAY:
well, you'll have to see for yourself... each node is added as a
child to the previous node... and when you mix the order around a
little and add things in a different order things get less predictable.