dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Flash Mx: Xpath Counting Nodes

  1. #1
    Member
    Join Date
    Mar 2007
    Posts
    56

    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

  2. #2
    Member
    Join Date
    Mar 2007
    Posts
    56
    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 !

  3. #3
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    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

  4. #4
    Member
    Join Date
    Mar 2007
    Posts
    56
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center