View Single Post
  #1 (permalink)  
Old May 25th, 2009, 03:04 AM
Nagaraj Nagaraj is offline
Authorized User
 
Join Date: Apr 2009
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default Count and replace

Hi,

XML:
Code<tableset>
<table id="acprof-9780199226009-table-1" frame="none">
<tgroup cols="4">
<colspec colnum="1" colname="col1"/>
<colspec colnum="2" colname="col2"/>
<colspec colnum="3" colname="col3"/>
<colspec colnum="4" colname="col4"/>
<thead>
<row rowsep="1">
<entry colname="col1"/>
<entry colname="col2" align="center">
<p>
<b>UK</b>
</p>
</entry>
<entry colname="col3" align="center">
<p>
<b>France</b>
</p>
</entry>
<entry colname="col4" align="center">
<p>
<b>Germany</b>
</p>
</entry>
</row>
</thead>
<tbody>
<row>
<entry colname="col1" align="left">
<p>Industry</p>
</entry>
<entry colname="col2" align="char" char=".">
<p>17.5</p>
</entry>
<entry colname="col3" align="char" char=".">
<p>14.4</p>
</entry>
<entry colname="col4" align="char" char=".">
<p>25.4</p>
</entry>
</row>

</tbody>
</tgroup>
</table>
<table id="acprof-9780199226009-table-1" frame="none">
<tgroup cols="4">
<colspec colnum="1" colname="col1"/>
<colspec colnum="2" colname="col2"/>
<colspec colnum="3" colname="col3"/>
<colspec colnum="4" colname="col4"/>
<thead>
<row rowsep="1">
<entry colname="col1"/>
<entry colname="col2" align="center">
<p>
<b>UK</b>
</p>
</entry>
<entry colname="col3" align="center">
<p>
<b>France</b>
</p>
</entry>
<entry colname="col4" align="center">
<p>
<b>Germany</b>
</p>
</entry>
</row>
</thead>
<tbody>
<row>
<entry colname="col1" align="left">
<p>Industry</p>
</entry>
<entry colname="col2" align="char" char=".">
<p>17.5</p>
</entry>
<entry colname="col3" align="char" char=".">
<p>14.4</p>
</entry>
<entry colname="col4" align="char" char=".">
<p>25.4</p>
</entry>
</row>

<row>
<entry colname="col1" align="left">
<p>Industry</p>
</entry>
<entry colname="col2" align="char" char=".">
<p>17.5</p>
</entry>
<entry colname="col3" align="char" char=".">
<p>14.4</p>
</entry>
<entry colname="col4" align="char" char=".">
<p>25.4</p>
</entry>
</row>
</tbody>
</tgroup>
</table>
</tableset>

Need output xml:

Code<tableset>
<table id="acprof-9780199226009-table-1" totalrow="2" frame="none">
<tgroup cols="4">
<colspec colnum="1" colname="col1"/>
<colspec colnum="2" colname="col2"/>
<colspec colnum="3" colname="col3"/>
<colspec colnum="4" colname="col4"/>
<thead>
<row rowsep="1">
<entry colname="col1"/>
<entry colname="col2" align="center">
<p>
<b>UK</b>
</p>
</entry>
<entry colname="col3" align="center">
<p>
<b>France</b>
</p>
</entry>
<entry colname="col4" align="center">
<p>
<b>Germany</b>
</p>
</entry>
</row>
</thead>
<tbody>
<row>
<entry colname="col1" align="left">
<p>Industry</p>
</entry>
<entry colname="col2" align="char" char=".">
<p>17.5</p>
</entry>
<entry colname="col3" align="char" char=".">
<p>14.4</p>
</entry>
<entry colname="col4" align="char" char=".">
<p>25.4</p>
</entry>
</row>
</tbody>
</tgroup>
</table>
<table id="acprof-9780199226009-table-1" totalrow="3" frame="none">
<tgroup cols="4">
<colspec colnum="1" colname="col1"/>
<colspec colnum="2" colname="col2"/>
<colspec colnum="3" colname="col3"/>
<colspec colnum="4" colname="col4"/>
<thead>
<row rowsep="1">
<entry colname="col1"/>
<entry colname="col2" align="center">
<p>
<b>UK</b>
</p>
</entry>
<entry colname="col3" align="center">
<p>
<b>France</b>
</p>
</entry>
<entry colname="col4" align="center">
<p>
<b>Germany</b>
</p>
</entry>
</row>
</thead>
<tbody>
<row>
<entry colname="col1" align="left">
<p>Industry</p>
</entry>
<entry colname="col2" align="char" char=".">
<p>17.5</p>
</entry>
<entry colname="col3" align="char" char=".">
<p>14.4</p>
</entry>
<entry colname="col4" align="char" char=".">
<p>25.4</p>
</entry>
</row>
<row>
<entry colname="col1" align="left">
<p>Industry</p>
</entry>
<entry colname="col2" align="char" char=".">
<p>17.5</p>
</entry>
<entry colname="col3" align="char" char=".">
<p>14.4</p>
</entry>
<entry colname="col4" align="char" char=".">
<p>25.4</p>
</entry>
</row>
</tbody>
</tgroup>
</table>
</tableset>

counting the each table tag inside the <row>tag, and place the counting value in the table attribute value like totalrow="2", which is highlighted in the red text.

Anyone help me how to counting the element in perl scripting...

Regards,
Nagaraj
Reply With Quote