2 Replies Latest reply on Aug 25, 2008 10:53 PM by The Bruder

    XML reading question

    The Bruder
      Hi all,

      I'm trying to read XML that looks like this:

      --------------------------------------
      <root>
      <the-keys name="key1"/>
      <the-keys name="key2"/>
      <the-keys name="key3"/>
      </root>
      -----------------------------------------

      with the AS code:

      ----------------------------------------------------------
      for each (var field : XML in root.the-keys) {
      ...
      }
      ---------------------------------------------------------

      and get error:
      "Syntax error: expecting identifier before the-keys"

      does someone has idea how to read this XML?
        • 1. Re: XML reading question
          Level 7

          "The Bruder" <webforumsuser@macromedia.com> wrote in message
          news:g8v1la$siu$1@forums.macromedia.com...
          > Hi all,
          >
          > I'm trying to read XML that looks like this:
          >
          > --------------------------------------
          > <root>
          > <the-keys name="key1"/>
          > <the-keys name="key2"/>
          > <the-keys name="key3"/>
          > </root>
          > -----------------------------------------
          >
          > with the AS code:
          >
          > ----------------------------------------------------------
          > for each (var field : XML in root.the-keys) {
          > ...
          > }
          > ---------------------------------------------------------
          >
          > and get error:
          > "Syntax error: expecting identifier before the-keys"
          >
          > does someone has idea how to read this XML?

          I don't think e4x likes hyphens in names too much. Try

          for each (var field:XML in yourXML.child('the-keys')

          HTH;

          Amy


          • 2. Re: XML reading question
            The Bruder Level 1
            Works!

            Thanks a lot!