Extracting XML Data

Hi,

I have the following XML structure:

 
<?xml version="1.0" encoding="UTF-8"?>
<page>
<component>
<bespoke>
<text-block id="varTitle">
<p>Products</p>
</text-block>
<text-block id="var0">
<p>Welcome to My Products.</p>
<p>Another paragraph</p>
<p>Yet Another paragraph</p>
</text-block>
<text-block id="var1">
<p/>
</text-block>
<text-block id="var2">
<p>In this section you'll find out:<br></p>
<ul>
<li>
<p>Which Products are sold globally</p>
</li>
<li>
<p>Which product options are available </p>
</li>
<li>
<p>Why the product is the ultimate in technology</p>
</li>
<li>
<p>How our excellence has been rewarded</p>
</li>
</ul>
</text-block>
</bespoke>
</component>
</page>

When I extract the data I need to preserve the html tags

,

    and
  • . I also need to ensure that each element is stored as a single value as each has an associated textfield in flash.

    This is what I have at the moment:

     
    function parseContent(content_xml) {
     var items = content_xml.firstChild.firstChild.firstChild.childNodes;
     for (var i = 0; i<items.length; i++) {
      var strText = "";
      if (items*.nodeName == "text-block") {
       //This is a sub loop that concatenates all the <p> nodes within the <text-block> node
       //a <text-block> node is made up of at least one <p> childNode
       var p_items = items*.childNodes;
       for (var p = 0; p<p_items.length; p++) {
        strText = strText+items*.childNodes[p];
        trace(strText);
       }
       myXML* = strText;
       //trace(myXML*);
      }
     }
    } 
    
    

    This will parse child elements of the <text-block> but will not work with <ul> as it has its own child elements <li>. I guess this could be accomplished with yet another loop but I wanted to check to see if there was another simpler way.

    Thanks in advance for any input.

    T.