Geeks With Blogs

Post Categories

The Lanham Factor The (ir)rational thoughts of a (not-so)mad man

Does anyone reading this have an XSLT script that determines the number of elements in an XML file (obviously) with a certain attribute equal to a certain value?  For example, suppose you have an XML file similar to the following:

<root>

     <someElem Status="closed"/>

     <someElem Status="open"/>

</root>

I want to count the number of "closed" items, etc.  I have some references and books but it's becoming a big hassle.  They all seem to want to specify the query using Elements instead of Attributes.  Thanks in advance!

Posted on Tuesday, February 26, 2008 6:33 AM Cutting Code | Back to top


Comments on this post: XSLT Anyone?

# re: XSLT Anyone?
Requesting Gravatar...
<xsl:select value="count(//*[@Status = 'closed'])" />
Left by Ivan Pepelnjak on Feb 26, 2008 6:56 AM

# re: XSLT Anyone?
Requesting Gravatar...
Sorry, should have been

<xsl:value-of select="count(//*[@Status = 'closed'])" />

The flu is obviously cooking my brains :(
Left by Ivan Pepelnjak on Feb 26, 2008 6:59 AM

Your comment:
 (will show your gravatar)


Copyright © Brian Lanham | Powered by: GeeksWithBlogs.net