我确实找到了这段代码(稍加编辑):
var destinations:XML = <destinations>
<destination location="japan">
<exchangeRate>400</exchangeRate>
<placesOfInterest>Samurai History</placesOfInterest>
</destination>
<destination location="australia">
<exchangeRate>140</exchangeRate>
<placesOfInterest>Surf and BBQ</placesOfInterest>
</destination>
<destination location="peru">
<exchangeRate>30</exchangeRate>
<placesOfInterest>Food</placesOfInterest>
</destination>
</destinations>;
//FILTER BY ATTRIBUTE NAME -------------------
var filteredByLocation:XMLList = destinations.destination.(@location == "japan");
trace("Attribute Name: "+filteredByLocation);
//FILTER BY NODE VALUE ----------------------
var filteredByExchangeRate:XMLList = destinations.destination.(exchangeRate < 200);
trace("Node Value: "+filteredByExchangeRate);
我想知道是否可以做相反的事情。我的意思是,获取所有内容,但不是具有属性名称的节点。
提前感谢您的帮助。
答案 0 :(得分:0)
我太困了。
//FILTER BY ATTRIBUTE NAME -------------------
var filteredByLocation:XMLList = destinations.destination.(@location != "japan");
trace("Attribute Name: "+filteredByLocation);
无论如何,它对那里的某人有用。