Native XML structure:

<?xml version="1.0" encoding="utf-8" ?>
<tree>
    <node name="root">
        <node name="TELEVISIONS">
            <node name="TUBE"/>
            <node name="LCD"/>
            <node name="PLASMA"/>
        </node>
        <node name="PORTABLE ELECTRONICS">
            <node name="MP3 PLAYERS">
                <node name="FLASH"/>
            </node>
            <node name="CD PLAYERS"/>
            <node name="2 WAY RADIOS"/>
        </node>
    </node>
</tree>

Flattened XML structure (example 1):

<tree>
  <node key="0">root</node>
  <node key="1" parent="0">TELEVISIONS</node>
  <node key="2" parent="1">TUBE</node>
  <node key="3" parent="1">LCD</node>
  <node key="4" parent="1">PLASMA</node>
  <node key="5" parent="0">PORTABLE ELECTRONICS</node>
  <node key="6" parent="5">MP3 PLAYERS</node>
  <node key="7" parent="6">FLASH</node>
  <node key="8" parent="5">CD PLAYERS</node>
  <node key="9" parent="5">2 WAY RADIOS</node>
</tree>

Flattened XML structure (example 2):

<tree>
    <node>
        <name>root</name>
        <depth>0</depth>
    </node>
    <node>
        <name>TELEVISIONS</name>
        <depth>1</depth>
    </node>
    <node>
        <name>TUBE</name>
        <depth>2</depth>
    </node>
    <node>
        <name>LCD</name>
        <depth>2</depth>
    </node>
    <node>
        <name>PLASMA</name>
        <depth>2</depth>
    </node>
    <node>
        <name>PORTABLE ELECTRONICS</name>
        <depth>1</depth>
    </node>
    <node>
        <name>MP3 PLAYERS</name>
        <depth>2</depth>
    </node>
    <node>
        <name>FLASH</name>
        <depth>3</depth>
    </node>
    <node>
        <name>CD PLAYERS</name>
        <depth>2</depth>
    </node>
    <node>
        <name>2 WAY RADIOS</name>
        <depth>2</depth>
    </node>
</tree>
By Anonymous, 2015-11-19 12:32:25