tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rashmi Rubdi <>
Subject Is it possible to count number of XML nodes in a node-set with JSTL XML tags?
Date Fri, 08 Sep 2006 06:43:31 GMT
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"?>
 <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>
  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?

Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message