Java Program to edit file to select records
<p>I have the following XML file:</p>

<pre><code>&lt;graph caption="ECG Data Wave" subcaption="For Person's Name" xAxisName="Time" yAxisMinValue="-0.025" yAxisName="Voltage" decimalPrecision="5" formatNumberScale="0" numberPrefix="" showNames="1" showValues="0" showAlternateHGridColor="1" AlternateHGridColor="ff5904" divLineColor="ff5904" divLineAlpha="20" alternateHGridAlpha="5"&gt;
    &lt;set name="12:00:00.01" value="0.600000" hoverText = "The difference from last value: 0" &gt;&lt;/set&gt;
    &lt;set name="12:00:00.02" value="0.640000" hoverText = "The difference from last value: 0.04" &gt;&lt;/set&gt;
    &lt;set name="12:00:01.025" value="0.340000" hoverText = "The difference from last value: -0.3" &gt;&lt;/set&gt;
    &lt;set name="12:00:01.031" value="0.100000" hoverText = "The difference from last value: -0.24" &gt;&lt;/set&gt;
    &lt;set name="12:00:01.039" value="-0.100000" hoverText = "The difference from last value: -0.2" &gt;&lt;/set&gt;
    &lt;set name="12:00:01.050" value="-0.200000" hoverText = "The difference from last value: -0.1" &gt;&lt;/set&gt;
    &lt;set name="12:00:02.01" value="0.010000" hoverText = "The difference from last value: 0.21" &gt;&lt;/set&gt;
    &lt;set name="12:00:02.12" value="0.600000" hoverText = "The difference from last value: 0.59" &gt;&lt;/set&gt;
    &lt;set name="12:00:02.23" value="0.500000" hoverText = "The difference from last value: -0.1" &gt;&lt;/set&gt;
    &lt;set name="12:00:02.028" value="0.300000" hoverText = "The difference from last value: -0.2" &gt;&lt;/set&gt;
    &lt;set name="12:00:02.031" value="0.100000" hoverText = "The difference from last value: -0.2" &gt;&lt;/set&gt;
    &lt;set name="12:00:03.049" value="0.000000" hoverText = "The difference from last value: -0.1" &gt;&lt;/set&gt;
    &lt;set name="12:00:03.145" value="-0.050000" hoverText = "The difference from last value: -0.05" &gt;&lt;/set&gt;
    &lt;set name="12:00:04.12" value="0.110000" hoverText = "The difference from last value: 0.16" &gt;&lt;/set&gt;
    &lt;trendlines&gt;
      &lt;line startvalue="0.30" displayValue="High Activity" color="FF0000" thickness="1" isTrendZone="0"&gt;&lt;/line&gt;
      &lt;line startvalue="-0.05" displayValue="Low Activity" color="009999" thickness="1" isTrendZone="0"&gt;&lt;/line&gt;
    &lt;/trendlines&gt;
&lt;/graph&gt;
</code></pre>

<p>I want to write a Java program that will allow users to select a starting range and an end range so that only those data points end up in the new file. For example, suppose the user wants the 2nd value to the 6th value so the new XML File is as follows:</p>

<pre><code>&lt;graph caption="ECG Data Wave" subcaption="For Person's Name" xAxisName="Time" yAxisMinValue="-0.025" yAxisName="Voltage" decimalPrecision="5" formatNumberScale="0" numberPrefix="" showNames="1" showValues="0" showAlternateHGridColor="1" AlternateHGridColor="ff5904" divLineColor="ff5904" divLineAlpha="20" alternateHGridAlpha="5"&gt;
   &lt;set name="12:00:00.02" value="0.640000" hoverText = "The difference from last value: 0.04" &gt;&lt;/set&gt;
   &lt;set name="12:00:01.025" value="0.340000" hoverText = "The difference from last value: -0.3" &gt;&lt;/set&gt;
   &lt;set name="12:00:01.031" value="0.100000" hoverText = "The difference from last value: -0.24" &gt;&lt;/set&gt;
   &lt;set name="12:00:01.039" value="-0.100000" hoverText = "The difference from last value: -0.2" &gt;&lt;/set&gt;
   &lt;set name="12:00:01.050" value="-0.200000" hoverText = "The difference from last value: -0.1" &gt;&lt;/set&gt;
   &lt;trendlines&gt;
     &lt;line startvalue="0.30" displayValue="High Activity" color="FF0000" thickness="1" isTrendZone="0"&gt;&lt;/line&gt;
     &lt;line startvalue="-0.05" displayValue="Low Activity" color="009999" thickness="1" isTrendZone="0"&gt;&lt;/line&gt;
   &lt;/trendlines&gt;
&lt;/graph&gt;
</code></pre>

<p>How is the best way to achieve this? Some people have suggested using Arrays, while others lists, so a bit confused.</p>

<p>Regards, 
Anthony.</p>

<p>Well I have some code but its not great to be honest from a different XML file that I parsed and just returned the data to screen. It used </p>

<pre><code>javax.xml.parsers.DocumentBuilder; 
javax.xml.parsers.DocumentBuilderFactory; 
java.io.File; 
org.w3c.dom.Document;
org.w3c.dom.Element;
org.w3c.dom.Node;
org.w3c.dom.NodeList;
</code></pre>

<p>if that is any help?</p>
