5 Replies Latest reply on Jun 25, 2007 8:29 PM by leeng

    problem with XML search with E4X

    leeng
      Hello,

      it seems like I am making a simple mistake somewhere, or I'm missing a concept somewhere. I have a simple xml file- see below that when I use e4x notation I can get the attribute for any node fine, but when I use e4x notation to search for a node with a particular attribute value I get the error message "attribute @<myattr> not defined" It's the same xml file so I can't figure out why it reads it one way and not the other.

      see code below:

      private function getRoomData():XML
      {
      var ftest:XML =
      <aaa>
      <bbb>
      <ccc id="2">Hello!</ccc>
      <ccc id="3">Goodbye</ccc>
      <ccc name="fred">Welcome</ccc>
      </bbb>
      </aaa>;
      var result:XMLList = ftest.bbb.ccc.(@name=="fred");
      trace(ftest.bbb.ccc.@name);
      trace(typeof ftest.bbb.ccc);
      trace(result);
      trace(typeof result);
      }

      the line uncommented is teh one that generates the message "@name is undefined" , however the trace line below it returns the attribute fine.

      I know it's something simple but I can't put my hand on it. Any help would be appreciated. Thanks. Am I missing an import library for e4x to work?

      be well,
      hoyt