views:

147

answers:

1

ok here is my code:

var xml:XML = 
<xml>
    <typeA amount1="500" amount2="300" amount3="250" date="2008-02-17"/>
    <typeA amount1="500" amount2="300" amount3="250" date="2008-02-16"/>
    <typeA amount1="500" amount2="300" amount3="250" date="2008-02-17"/>
    <typeB amount1="500" amount2="300" amount3="250" date="2008-02-18"/>
    <typeB amount1="500" amount2="300" amount3="250" date="2008-02-19"/>
    <typeC amount1="500" amount2="300" amount3="250" date="2008-02-20"/>
    <typeC amount1="500" amount2="300" amount3="250" date="2008-02-21"/>
    <typeC amount1="500" amount2="300" amount3="250" date="2008-02-20"/>
</xml>;


trace(xml.typeA.(@date == "2008-02-16")); // no results
trace(xml.typeA.(@date == "2008-02-17")); // finds both
trace(xml.typeC.(@date == "2008-02-20")); // finds both
trace(xml.typeC.(@date == "2008-02-21")); // no results

It seems like it is only finding it if there is more then 1 occurance.

Am I doing something wrong?

+4  A: 

Actually it finds it but because it's only one item it traces it as an XML (instead of XMList). The node being empty it will just trace an empty string.

Try this :

<typeA amount1="500" amount2="300" amount3="250" date="2008-02-16">Hello</typeA>

When you are debugging XML you'd better use the toXMLString method.

trace(xml.*.(@date="1980-04-29").toXMLString());
Theo.T