AS3 Dealing with dashes in XML node names


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. // Note the method of traversing the node <amount-list> using child("amount-list")
  2. // This encloses the dash in the amount-list name so that Flash can deal with it
  3. // Using (xmlData.gamedata.amount-list.amount.(@currency=="eur")) does not work
  4. // giving error: Access of undefined property list
  5.  
  6. var xmlData:XML =
  7. <request info="1" game="ab">
  8. <gamedata game="ab" timestamp="1320313349">
  9. <amount-list>
  10. <amount currency="usd" step="1" pos="1">100</amount>
  11. <amount currency="eur" step="2" pos="2">200</amount>
  12. <amount currency="gbp" step="3" pos="3">300</amount>
  13. </amount-list>
  14. </gamedata>
  15. </request>
  16.  
  17. var amt:int = (xmlData.gamedata.child("amount-list").amount.(@currency=="eur"));
  18.  
  19. trace(amt); // 200

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.