2011-02-15 100 views
1

我想在這裏使用XML在Flash中遇到問題。我需要收集包含特定值的某個子節點的XMLList中的所有節點。例如,從下面的XML我只想得到''產品''節點,其中1作爲「量」的值,即產品3和5.如何讓所有包含某個特定子節點的xml節點在as3中具有特定值?

而且這不是產品3的拼寫錯誤...;(

<xml> 
    <product> 
     <title>Product 1</title> 
     <amount>4</amount> 
    </product> 
    <product> 
     <title>Product 2</title> 
     <amount>4</amount> 
    </product> 
    <product> 
     <title>Product 3</title> 
     <amount>7</amount> 
     <amount>1</amount> 
    </product> 
    <product> 
     <title>Product 4</title> 
     <amount>4</amount> 
    </product> 
    <product> 
     <title>Product 5</title> 
     <amount>1</amount> 
    </product> 
</xml> 
+0

xml.product(量== 1)是一個開始,但它會排除。一個有兩個金額 – 2011-02-15 08:51:39

回答

0

如果xml高於XML對象,則:

var xmlList:XMLList = xml.product.(amount == 1); 
trace(xmlList.toString()); 
+0

這會開啓如果``沒有多於一個'`,則工作。 – weltraumpirat 2011-02-15 09:23:10

1
var list : XMLList = xml.product.(amount.(valueOf() == 1).length() > 0); 
相關問題