2 Replies Latest reply on Nov 3, 2008 11:03 AM by dmindler

    Getting the parent node only in XML

    Galwegian
      I have the following bit of XML, file is called "theXML". I want to be able to read the first and second children of this peice of XML without reading their children. i.e. I want app1 and app2

      <application>
      <app1 name="App1">
      <module id="1"/>
      <module id="2"/>
      </app1>
      <app2 name="App2">
      <module id="3"/>
      </app2>
      </application>

      I have the following bit of code, but instead of just getting the two nodes I want, it get the nodes and their children

      theXML.child("*")

      That gives me

      <app1 name="App1">
      <module id="1"/>
      <module id="2"/>
      </app1>
      <app2 name="App2">
      <module id="3"/>
      </app2>

      How do I just get the two nodes app1 and app2?
        • 1. Re: Getting the parent node only in XML
          Level 7

          "Galwegian" <webforumsuser@macromedia.com> wrote in message
          news:gemq1r$t77$1@forums.macromedia.com...
          >I have the following bit of XML, file is called "theXML". I want to be able
          >to
          > read the first and second children of this peice of XML without reading
          > their
          > children. i.e. I want app1 and app2
          >
          > <application>
          > <app1 name="App1">
          > <module id="1"/>
          > <module id="2"/>
          > </app1>
          > <app2 name="App2">
          > <module id="3"/>
          > </app2>
          > </application>
          >
          > I have the following bit of code, but instead of just getting the two
          > nodes I
          > want, it get the nodes and their children
          >
          > theXML.child("*")
          >
          > That gives me
          >
          > <app1 name="App1">
          > <module id="1"/>
          > <module id="2"/>
          > </app1>
          > <app2 name="App2">
          > <module id="3"/>
          > </app2>
          >
          > How do I just get the two nodes app1 and app2?

          theXML.children().toString()


          • 2. Re: Getting the parent node only in XML
            dmindler

            more specifically:

            theXml.children()[0]
            theXml.children()[1]

            use children().length() to get the number of kids


            http://livedocs.adobe.com/flex/2/langref/XML.html#children()