4 Replies Latest reply on Jan 27, 2008 9:53 AM by wrkoch

    Need help - How to Validate XML

      I have just started playing around with XML in Flex2 and can't figure out a few things. I have the following XML

      var myData:XML =
      <ITEM_001 ITEM_NAME="TOLERANCE">10</ITEM_001>
      <ITEM_002 ITEM_NAME="DIA A">.25</ITEM_002>
      <ITEM_003 ITEM_NAME="DIA B">.5</ITEM_003>
      <ITEM_001 ITEM_NAME="TOLERANCE">150</ITEM_001>
      <ITEM_002 ITEM_NAME="DIA A">.25</ITEM_002>
      <ITEM_003 ITEM_NAME="DIA B">.73</ITEM_003>

      I want the extract the element name ITEM_00x from with the row to use as a string in another portion of the app. For example, I can get to the ITEM_NAME attribute (TOLERANCE) and to the value (like 10). I can't figure out how to extract ITEM_001 short of creating an XMLString and parsing it out. I'm sure there must be a function or some other simple way to get it but I don't know what it is.

      Another thing I'd like to do is validate the xml somehow so I can insure that I have a good format. Not sure how to do this in Flex2. I'm uploading XML via HTTPService (e4X format) from users. The only caveat is that the number of elements in each row can vary depending on whom I get the xml from. I may have ITEM_001 thru ITEM_010 in each row the first time and ITEM_001 thru ITEM_005 the next.

      Any help would be appreciated!

      Warren Koch