If you want to check how many books are there, you can do something like following-
var bookXML = new XML(xmlDoc)
var books = bookXML['book'];
var length = books.length();
Note: I haven't worked much on XML suffs so there can be some syntax errors.
Please let me know, it it doesn't work.
:)