PHP 5.3.0 --- echo $sxe->asXML() displays incorrectly...

29 views
Skip to first unread message

wilbcorp

unread,
Nov 17, 2009, 1:45:39 PM11/17/09
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.

Honza (Jan Odvarko)

unread,
Nov 19, 2009, 4:10:28 AM11/19/09
to Firebug
This is not a Firebug bug. What you see in the HTML panel is exactly
how the page looks like after parsing the source.
Honza
Reply all
Reply to author
Forward
0 new messages