Xml/Xslt - how to get the length of childnodes using the attribute in parent node?

Asked By vsd on 26-Sep-13 06:49 AM
<test>
 <book id="book1">
    <author>xxx</author>
    <year>123</year>
  </book>
  <book id="book2">
    <author>yyy</author>
  </book>
</test>

How to get the count of the childnodes. for eexample for "book1" i need to get the result as 2 and for "book2" i need result as 1. i am using xml dom. kindly help 
Robbe Morris replied to vsd on 26-Sep-13 08:47 AM
var list = xml.selectNodes("//book");

Look for a .count or .length property on list.