Re: Counting specific elements in a XML object
- From: showaltb@xxxxxxxxx (Bob Showalter)
- Date: Thu, 30 Mar 2006 16:32:26 -0500
Chas Owens wrote:
If we are going to pick nits then it should be
grep -c "<employee>" fn
Note that grep -c counts matching *lines*. There is no formal requirement that these elements appear on separate lines.
Here's a slightly more complex Perl one-liner that counts *occurences*
perl -lne '$n++ for /<employee>/g; END {print $n}' somefile.xml
.
- Follow-Ups:
- Re: Counting specific elements in a XML object
- From: Hans Meier
- Re: Counting specific elements in a XML object
- References:
- RE: Counting specific elements in a XML object
- From: Gavin Bowlby
- Re: Counting specific elements in a XML object
- From: Hans Meier
- Re: Counting specific elements in a XML object
- From: Chas Owens
- RE: Counting specific elements in a XML object
- Prev by Date: Re: store Array in hash ?
- Next by Date: Re: store Array in hash ?
- Previous by thread: Re: Counting specific elements in a XML object
- Next by thread: Re: Counting specific elements in a XML object
- Index(es):