Rashmi Rubdi wrote:
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?
Hm, this works though (Standard 1.1.2):
<c:import url="books.xml" var="xml" charEncoding="UTF-8" />
<x:parse doc="${xml}" var="xml_doc" />
<x:set var="book" select="$xml_doc/books/book" />
<x:out select="count($book)"/>
-Rashmi
--
Kris Schneider <mailto:[EMAIL PROTECTED]>
D.O.Tech <http://www.dotech.com/>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]