1. 根据节点属性查找:
代码
var flexXML:XML =
<RIA>
<FlashPlayer>
<Flash version="9">Flash CS3</Flash>
<Flash version="8">Flash 8</Flash>
<Flash version="7">Flash 2004MX</Flash>
<Flex>Flex3</Flex>
</FlashPlayer>
<Ajax>
<GoogleAjax>GoogleAjax1.0</GoogleAjax>
</Ajax>
</RIA>;
trace(flexXML.FlashPlayer.Flash.(attribute("version")>7));
<RIA>
<FlashPlayer>
<Flash version="9">Flash CS3</Flash>
<Flash version="8">Flash 8</Flash>
<Flash version="7">Flash 2004MX</Flash>
<Flex>Flex3</Flex>
</FlashPlayer>
<Ajax>
<GoogleAjax>GoogleAjax1.0</GoogleAjax>
</Ajax>
</RIA>;
trace(flexXML.FlashPlayer.Flash.(attribute("version")>7));
2. 根据节点内容查找:
根据内容查找
var flexXML1:XML=
<RIA>
<FlashPlayer>
<Flash>
<Name>Flash CS3</Name>
<Version>9</Version>
</Flash>
<Flash>
<Name>Flash 8</Name>
<Version>8</Version>
</Flash>
<Flash>
<Name>Flash 2004MX</Name>
<Version>7</Version>
</Flash>
<Flex>Flex3</Flex>
</FlashPlayer>
</RIA>
trace(flexXML1.FlashPlayer.Flash.(Version>7));
<RIA>
<FlashPlayer>
<Flash>
<Name>Flash CS3</Name>
<Version>9</Version>
</Flash>
<Flash>
<Name>Flash 8</Name>
<Version>8</Version>
</Flash>
<Flash>
<Name>Flash 2004MX</Name>
<Version>7</Version>
</Flash>
<Flex>Flex3</Flex>
</FlashPlayer>
</RIA>
trace(flexXML1.FlashPlayer.Flash.(Version>7));
查找返回的是 XMLList对象。