I have a few XML files and would like to count how many times the tag <para>
occurs.
<values>
<fnstance>
<value>00</value>
<description>
<para>Some text.</para>
</description>
</finstance>
<finstance>
<value>01</value>
<description>
<para>When this text</para>
</description>
<description>
<para>Some other text for same value</para>
</description>
</finstance>
</values>
I would like to find the tag <para>
and count them for a each <value>
tag. Is there a way to do this in Unix?
I tried xml_grep 'finstance' ../../recent/*.xml | xargs | grep -o '<para>'
which gives me the list of <para>
elements in a give file. But I don't know how to do that for each value tag. How to do this?