0 Replies Latest reply on Dec 16, 2014 5:31 AM by imoverhere

    How can i filter an xml object on an attribute?

    imoverhere

      I want address an xml object with .(@ attributeNameHere == "textToSearchForHere") and have it return the node it’s associated with. 

      This is the text from the adobe help site and it’s similar to my actual code.  I’m querying this xml object: staticVar.employee.(@id=="347").  FlashBuilder 4.7 is returning an error “No such variable: @id”. when I look in debugger.


      This example is found in Adobe's help site: Adobe Flash Platform * Traversing XML structures

       

      The help site says

      The following expressions are all valid:

      • x.employee.(lastName == "McGee")—This is the secondemployeenode.
      • x.employee.(lastName == "McGee").firstName—This is thefirstNameproperty of the secondemployeenode.
      • x.employee.(lastName == "McGee").@id—This is the value of theidattribute of the secondemployeenode.
      • x.employee.(@id == 347)—The firstemployeenode.

       

       

      public var staticVar:XML = 

      <employeeList>

            <employee id="347">

                 <lastName>Zmed</lastName>

                 <firstName>Sue</firstName>

                 <position>Data analyst</position>

            </employee>

            <employee id="348">

                 <lastName>McGee</lastName>

                 <firstName>Chuck</firstName>

                 <position>Jr. data analyst</position>

            </employee>

      </employeeList>;

       

      I’m expecting this: staticVar.employee.(@id=="347") will return the following node:

      <employee nu="347">

      <lastName>Zmed</lastName>

      <firstName>Sue</firstName>

      <position>Data analyst</position>

      </employee>

       

      If this is the wrong, then what is the correct way to access the xml node based on an attribute?  How can i get that node 347 in this example to be found and returned?  I've opened a ticket with the adobe help team and we're on the 8th day and they have not been helpful at all.