Is it possible to count number of XML nodes in a node-set with JSTL XML tags?
Rashmi Rubdi <[email protected]>
| Newsgroups | gmane.comp.jakarta.taglibs.user |
|---|---|
| Message-ID | <[email protected]> |
I searched for a solution for this but couldn't find an answer.
I'm trying to count the number of book nodes from the xml below:
<?xml version="1.0" encoding="UTF-8"?>
<books>
<book isbn="212112">Book Title 1</book>
<book isbn="212313">Book Title 2</book>
<book isbn="343444">Book Title 3</book>
<book isbn="343424">Book Title 4</book>
<book isbn="656433">Book Title 5</book>
</books>
I tried using XPath's count function, inside the JSP page, but it gives 0 instead of
5 - (the number of book nodes)
<c:import url="books.xml" var="xml" charEncoding="UTF-8" />
<x:parse doc="${xml}" var="xml_doc" />
<x:out select="count($xml_doc/books/book)"/>
Is it possible to obtain the count of a node set inside a JSP or do I have to first transform the source XML into another XML which obtains the count and then read the count from the second XML file?
-Rashmi
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com