2013-08-26 53 views
0

我發現這段代碼(稍微改動過):AS3 Flash CS5 - XML節點過濾器?

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); 

我想知道是否有可能做相反。我的意思是,獲得一切,但不是具有屬性名稱的節點。

在此先感謝您的幫助。

+1

試試'destinations.destination。(@ location!=「japan」);' – putvande

+0

Thanks @putvande。我在幾分鐘前測試過它。我想我必須避免提問睏倦。 – Sergio

回答

0

我太困:

//FILTER BY ATTRIBUTE NAME ------------------- 
var filteredByLocation:XMLList = destinations.destination.(@location != "japan"); 
trace("Attribute Name: "+filteredByLocation); 

無論如何,它可以是每個人都會有非常有用。