Hmm... it works if you nest the predicate bit to...

"//product[colors[clr= 'green']]"

...apparently (after quick google) this is legal XPath.


Chris Wilcox
________________________________


 
 
Bounce Digital Ltd  
12 Goslett Yard | London | WC2H 0EQ UK 
T +44(0)207 478 4488 | www.bouncedigital.co.uk
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Doug
Coning
Sent: 03 November 2005 12:13
To: Flashcoders mailing list
Subject: [Flashcoders] XPath Error...

Has anone encountered the following error that doesn't allow you to
query child nodes of a particular node?  Here is the sample code.  Sorry
for the wrapping:

-----------------------------------------------------------
import com.xfactorstudio.xml.xpath.*;
_global.XPath = XPath;

// XML
var myStr:String =
"<products><product><flag>0</flag><colors><clr>green</clr></colors><colo
rs><clr>red</clr></colors><name>Item
1</name><price>19.95</price></product><product><flag>1</flag><colors><cl
r>blue</clr><clr>red</clr></colors><name>Plate</name><price>12.95</price
></product><product><colors><clr>silver</clr></colors><flag>0</flag><nam
e>Spoon</name><price>4.95</price></product></products>";
var myXML:XML = new XML(myStr);
trace("myXML: " + myXML);

// Query 1
var result1_array:Array = XPath.selectNodes(myXML,"//product[colors/clr
= 'green']");
trace("\nGreen Results:\t" +  result1_array);
trace("Result Length:\t\t" +  result1_array.length);

// Query 2
var result2_array:Array = XPath.selectNodes(myXML,"//product[colors/clr
= 'red']");
trace("\nRed Results:\t" +  result2_array);
trace("Result Length:\t\t" +  result2_array.length);

Doug Coning 
Software Developer
FORUM Solutions, LLC
 
This e-mail and any attachment(s) are intended for the specified
recipient(s) only and are legally protected.  If you have received this
communication in error, please "reply to" sender's e-mail address with
notification of the error and then destroy this message in all
electronic and physical forms.
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
______________________________________________________________________



______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
______________________________________________________________________
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to