Flex E4X XML 常用语句

1.过滤
XML.item.(@id==2).menuName

XML.item.(menuName=="burger").price

2.创建XML
(1)用已知字符创建
<item id="5">Chicken</item>

(2)用变量创建
var x:XML = <{tagname} {attributename}={attributevalue}>{content}</{tagname}>

(3)用变量读取
其实就把XML看成是Object就好理解了,对于属性取值来说,"."运算和"[]"运算的意义是相同的.
var itemKey:String="item";
var idKey:String="id";
var menuNameKey:String="menuName";
var priceKey:String="price";
xml[itemKey].@[idKey]
xml[itemKey].(@[idKey] == "1").@[idKey]
xml[itemKey].(menuName == "burger").(attribute(idKey) == "1")[priceKey]
xml[itemKey].(elements(menuNameKey) == "burger").(@[idKey] == "1")[priceKey]


推荐官方解释
http://help.adobe.com/zh_CN/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7e6b.html

你可能感兴趣的:(java,xml,Flex)