4 Replies Latest reply on Oct 14, 2008 12:27 PM by Newsgroup_User

    Can't access XML children

    Handycam Level 1
      I must be missing something. I have an XML file with daily tips, and I want to display only todays tip. Each tip is:

      <tip>
      <date>31</date>
      <content>Tip content here</content>
      <link>URL to full tip here</link>
      </tip>

      I load the file, and create an XMLListCollection like so:

      private function dataHandler(e:ResultEvent):void {
      var dp:XML = new XML(e.result);
      coll = new XMLListCollection(dp.tip.(date==daysToGo));
      trace(coll);
      tip.text = coll..content;
      }

      The trace statement correctly displays today's tip node and its children. But this throws an error, can't even save:

      tip.text = coll.content;
        • 1. Re: Can't access XML children
          Gregory Lafrance Level 6
          What is tip in tip.text, a Label, Text, TextArea, TextInput?
          • 2. Re: Can't access XML children
            Level 7

            "Handycam" <webforumsuser@macromedia.com> wrote in message
            news:gd2jph$7jo$1@forums.macromedia.com...
            >I must be missing something. I have an XML file with daily tips, and I
            >want to
            > display only todays tip. Each tip is:
            >
            > <tip>
            > <date>31</date>
            > <content>Tip content here</content>
            > <link>URL to full tip here</link>
            > </tip>
            >
            > I load the file, and create an XMLListCollection like so:
            >
            > private function dataHandler(e:ResultEvent):void {
            > var dp:XML = new XML(e.result);
            > coll = new XMLListCollection(dp.tip.(date==daysToGo));
            > trace(coll);
            > tip.text = coll..content;
            > }
            >
            > The trace statement correctly displays today's tip node and its children.
            > But
            > this throws an error, can't even save:
            >
            > tip.text = coll.content;

            I think once you make it an XMLListCollection, you can't use e4x on it
            anyymore.

            Try

            tip.text=XML(coll.getItemAt(0)).child('content')

            HTH;

            Amy


            • 3. Re: Can't access XML children
              Handycam Level 1
              Thanks Amy.
              • 4. Re: Can't access XML children
                Level 7

                "Handycam" <webforumsuser@macromedia.com> wrote in message
                news:gd2oqe$dg9$1@forums.macromedia.com...
                > Thanks Amy.

                You're welcome :-)