3 Replies Latest reply on Oct 29, 2009 10:46 AM by hamburg1984

    Remove specific elements from a XMLList

    hamburg1984

      Hi,

       

      i've got an xml file which is structured like shown below.

       

      <?xml version="1.0" encoding="UTF-8"?>
      <data>
          <main id="1" name="Level1">
              <sub id="1" name="Level2">
                  <sub2 id="1" name="Level3">
                      <data id="1" name="Data1"/>
                      <data id="2" name="Data2"/>
                  </sub2>
                  <sub2 id="2" name="Level3_2">
                      <data id="3" name="Data3"/>
                      <data id="4" name="Data4"/>
                  </sub2>
              </sub>
          </main>
          <main>
      </data>

       

       

       

      This my application code

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal" creationComplete="svcXml.send()">
      <mx:Script>
           <![CDATA[
                [Bindable] private var fullXML:XMLList;
                import mx.rpc.events.ResultEvent;
                private function contentHandler(evt:ResultEvent):void{
                        fullXML = evt.result.data;
                     
                     
                } 
           ]]>
      </mx:Script>
      <mx:HTTPService id="svcXml" url="xmlfile.xml" result="contentHandler(event)" resultFormat="e4x"/>
         <mx:Tree id="menu" labelField="@name" width="300" height="100%" >
            <mx:XMLListCollection source="{fullXML}">
            </mx:XMLListCollection>
         </mx:Tree>

       


      </mx:Application>

       

      My question is: How do I ignore all <data> elements? I can't modify the xml file itself because it will be an external source.

       

      The generated tree should look like this:

       

      <tree>
          <level1>
              <level2>
                  <level3/>
                  <level3_2/>
              </level2>
          </level1>
          ....
      </tree>

       

       

      Thanks for your help!