-
Flash Mx: Xpath Counting Nodes
Greetings,
Does anyone know how to peform counts with Xpath?
Here's what i've grasped so far i.e. making sure Ive installed xpath api and thats about it really!!
I've done a best guess as I cant find any info on the web so far (see below) there's no syntax errors and the variable questionscount is 'undefined'.
Code:
import mx.xpath.XPathAPI;
var titlePath:String = "//quiz/title/items/";
var questionscount:Number = count.nodeValue(titlePath);
trace (questionscount);
Does anybody knwo the syntax and can help me out?
Would also be interesting to know how to count where the node value of "//quiz/title/items/category" is "XXXX" etc..,
Thanks
Rob
-
WOW, I found the syntax just need to work on it abit more ..
myData.firstChild.childNodes.length
http://saumyaray.wordpress.com/2006/...sh-xml-part-2/
Hope this helps other people too !
-
that tells you only how many siblings that node has not how many sub and sub-sub ect. thus total childs alltogether has.
ChildNodes will return you an array with XML Node elements- so in the end you count that array length
-
Thanks for the reply.
I did some experimenting and further reading and now functions just as I want it too
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|