Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 14th, 2011, 08:07 AM
Authorized User
 
Join Date: Apr 2011
Posts: 22
Thanks: 4
Thanked 0 Times in 0 Posts
Default Count elements start with

Hi,
Is there a way to count the number of nodes that start with a particular string?
I want to count all nodes that start with the name "Error". Is it possible using XSLT?

My Input XML will have Error elements but it can occur any number of times, as
<Error1 desc="Request Incomplete"/>
<Error2 desc="Could Not login"/>
<Error3 desc="Invalid password"/>

I need to count the number of times it occurs and post a message saying, "3 errors occured during operation".
 
Old July 14th, 2011, 08:15 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

count(//*[starts-with(local-name(), 'Error')])
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to check whether an elements contains another elements or not? metinhoclam XSLT 5 August 14th, 2010 10:11 AM
Chap 16 pg 574: Elements not supported Elements not known tomche BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 August 6th, 2009 02:48 PM
is there any in built function to count page count g.tamilselvan MySQL 1 February 15th, 2006 07:43 AM
Accurately Count Elements interrupt Javascript How-To 0 June 13th, 2005 02:21 AM
Count, sum, count a value, return records CongoGrey Access 1 April 18th, 2005 02:25 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.