Counting specific elements in a XML object



If I have a xml file like the following:

<?xml version='1.0'?>
<employee>
<name>John Doe</name>
<age>43</age>
<sex>M</sex>
<department>Recieving</department>
</employee>
<employee>
<name>Bob Gordon</name>
<age>50</age>
<sex>M</sex>
<department>Shipping</department>
</employee>


Is there some perl module out there that can help me get the number of
employees or in other words, the number occurences of "<employee>"?

I guess I can get it conventionally by reading in the file and doing a count
every time the script encounters "<name>". But there must be an easier way..

Any ideas?

DA


Relevant Pages

  • Re: Word Template with XML
    ... > I'm trying to create a Word Template, that reads and xml file when a new ... > The xml file contains information of all employees, ... > At startup the user should select an employee and then specific information ... > Shall I populate the data in a dataset first? ...
    (microsoft.public.dotnet.languages.vb)
  • Re: How to bind to XML??
    ... > Hi Ron, ... > I was able to read the xml file into a DataSet with no problem... ... Does the dataset contain one table for the employee data and another table ... then bind the combobox to the employee table and the datagrid to the details ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to bind to XML??
    ... I was able to read the xml file into a DataSet with no problem... ... I could also write an xml file for each employee. ... >> Any suggestions on how to bind an XML file to a combobox and datagrid? ...
    (microsoft.public.dotnet.languages.csharp)
  • help needed urgent
    ... working fine except when i need to save into the xml file ... var xmlDoc=new ActiveXObject ... root = xmlDoc.documentElement ...
    (microsoft.public.scripting.jscript)
  • Word Template with XML
    ... I'm trying to create a Word Template, that reads and xml file when a new ... The xml file contains information of all employees, ... At startup the user should select an employee and then specific information ... Shall I populate the data in a dataset first? ...
    (microsoft.public.dotnet.languages.vb)