Counting specific elements in a XML object

2006-03-30 Thread Dave Adams
If I have a xml file like the following: ?xml version='1.0'? employee nameJohn Doe/name age43/age sexM/sex departmentRecieving/department /employee employee nameBob Gordon/name age50/age sexM/sex departmentShipping/department

Re: Counting specific elements in a XML object

2006-03-30 Thread Hans Meier (John Doe)
Dave Adams am Donnerstag, 30. März 2006 21.12: If I have a xml file like the following: ?xml version='1.0'? employee nameJohn Doe/name age43/age sexM/sex departmentRecieving/department /employee employee nameBob Gordon/name age50/age

RE: Counting specific elements in a XML object

2006-03-30 Thread Gavin Bowlby
How about: cat fn | grep string to be searched for | wc as a non-Perl approach to the problem... -Original Message- From: Hans Meier (John Doe) [mailto:[EMAIL PROTECTED] Sent: Thursday, March 30, 2006 11:38 AM To: beginners@perl.org Subject: Re: Counting specific elements in a XML

Re: Counting specific elements in a XML object

2006-03-30 Thread Hans Meier (John Doe)
Gavin Bowlby am Donnerstag, 30. März 2006 21.45: How about: cat fn | grep string to be searched for | wc When I posted a cat | grep the first (and last) time, several people got a well known heart attack :-) grep string to be searched for fn | wc as a non-Perl approach to the problem...

Re: Counting specific elements in a XML object

2006-03-30 Thread Chas Owens
On 3/30/06, Hans Meier (John Doe) [EMAIL PROTECTED] wrote: Gavin Bowlby am Donnerstag, 30. März 2006 21.45: How about: cat fn | grep string to be searched for | wc When I posted a cat | grep the first (and last) time, several people got a well known heart attack :-) grep string to be

Re: Counting specific elements in a XML object

2006-03-30 Thread Hans Meier (John Doe)
Chas Owens am Donnerstag, 30. März 2006 22.35: cat fn | grep string to be searched for | wc [...] grep string to be searched for fn | wc [...] If we are going to pick nits then it should be grep -c employee fn too much work. c employee fn But your alias may be different ;-) Hans --

Re: Counting specific elements in a XML object

2006-03-30 Thread Bob Showalter
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

Re: Counting specific elements in a XML object

2006-03-30 Thread Hans Meier (John Doe)
Bob Showalter am Donnerstag, 30. März 2006 23.32: 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. Dave, my first one-liner