Please excuse me for the title!
I have a xml file but I am not parsing it. I am using R and reading the file using readLines
and applying functions like gsub()
etc to perform operations. I am applying a condition where "p" becomes ".p" but I do not want to apply it between "table" and "/table".
Input
<?xml version="1.0"?>
<h2>
<h4>
<hdtitle>Circuit Description</hdtitle>
<p>The commanded throttle position (TP)the values</p>
</h4>
<h4>
<hdtitle>DTC Descriptor</hdtitle>
<p>This diagnostic procedure supports the following DTC:</p>
<p>DTCP2101 Throttle Actuator Position Performance</p>
</h4>
<h4>
<hdtitle>Test Description</hdtitle>
<p>The numbers below refer to the step numbers on the diagnostic </p>
<exp-item id="td08">
<exp-itemnum>8</exp-itemnum>
<p>The throttle valve is spring pressure</p>
</exp-item>
<exp-item id="td11">
<exp-itemnum>11</exp-itemnum>
<p>When the ignition is</p>
</exp-item>
<table frame="all" pgwide="page-wide" titlesource="cell-title">
<tgroup align="left" char="" charoff="50" cols="4" colsep="1" rowsep="1">
<colspec charoff="50" colname="col1" colwidth="0.51in"/>
<colspec charoff="50" colname="col4" colwidth="1.40in"/>
<p>The numbers below refer to the step numbers </p>
</tgroup>
</table>
</h4>
</h2>
Output
<?xml version="1.0"?>
<h2>
<h4>
<hdtitle>Circuit Description</hdtitle>
<p>The commanded throttle position (TP)the values.</p>
</h4>
<h4>
<hdtitle>DTC Descriptor</hdtitle>
<p>This diagnostic procedure supports the following DTC:</p>
<p>DTCP2101 Throttle Actuator Position Performance.</p>
</h4>
<h4>
<hdtitle>Test Description</hdtitle>
<p>The numbers below refer to the step numbers on the diagnostic .</p>
<exp-item id="td08">
<exp-itemnum>8</exp-itemnum>
<p>The throttle valve is spring pressure.</p>
</exp-item>
<exp-item id="td11">
<exp-itemnum>11</exp-itemnum>
<p>When the ignition is</p>
</exp-item>
<table frame="all" pgwide="page-wide" titlesource="cell-title">
<tgroup align="left" char="" charoff="50" cols="4" colsep="1" rowsep="1">
<colspec charoff="50" colname="col1" colwidth="0.51in"/>
<colspec charoff="50" colname="col4" colwidth="1.40in"/>
<p>The numbers below refer to the step numbers </p>
</tgroup>
</table>
</h4>
</h2>
As you can see, ".p" is not applied between "table" and "/table". Please help!