A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
video training course this week in the
XML and Related Technologies
Counting Number of Occurences in XML
Joined: Oct 07, 2003
Jan 11, 2006 10:06:00
I have a well formed XML but not a well formatted XML like :
Now my requirement is to counter number of occurents in locale node for DE and FR locale.
For Example: Number of DE occurences is : 2
Number of FRoccurences is : 1
since the XML if not formatted so i cant use GREP for following
: grep "<locale>DE</locale>" <filename> | wc -l
Can anyone suggest me how can i count number of occurences in such an XML file whose format can change anytime.It may happen that entire thing is one line or may be as scattered as above.
Any quick help would be appreciated.Its urgent for me and i am stuck here.Can anyone guide me what can i do in quick time.
thanks in advance to everyone,
Success is not doing extraordinary things but doing ordinary things extraordinarily well.
Joined: Oct 14, 2005
Jan 11, 2006 10:17:00
Use XML-aware software instead of generic tools like grep. For example you could write an XSL transformation that uses the count() function.
Joined: Jun 03, 2000
Jan 11, 2006 10:53:00
Plus depending on how the "line break/carriage return/white-space character" is interpretted, you might end up with only ONE line and so only one count, right?
Take a Minute, Donate an Hour, Change a Life
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
subject: Counting Number of Occurences in XML
java.lang.IllegalStateException: using sendRedirect()
Help - JSF Tomcat Config Error
JDOM and Xml
How to change the Hello Portlet in Jetspeed2 Demo
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015