How to check for opening and closing tags in xml file using java?
<p>I have a xml file like the following:</p>

<pre><code>&lt;file&gt;
     &lt;students&gt;
          &lt;student&gt;
               &lt;name&gt;Arthur&lt;/name&gt;
               &lt;height&gt;168&lt;/height&gt;
          &lt;/student&gt;
          &lt;student&gt;
               &lt;name&gt;John&lt;/name&gt;
               &lt;height&gt;176&lt;/height&gt;
          &lt;/student&gt;
     &lt;/students&gt;
&lt;/file&gt;
</code></pre>

<p>How do I check whether for each opening tag, there is an ending tag? For example, if I do not provide the ending tag as: </p>

<pre><code>&lt;file&gt;
     &lt;students&gt;
          &lt;student&gt;
               &lt;name&gt;Arthur&lt;/name&gt;
               &lt;height&gt;168&lt;/height&gt;
          // Ending tag for student missing here
          &lt;student&gt;
               &lt;name&gt;John&lt;/name&gt;
               &lt;height&gt;176&lt;/height&gt;
          &lt;/student&gt;
     &lt;/students&gt;
&lt;/file&gt;
</code></pre>

<p>How do I continue parsing the rest of the file?</p>

<p>I tried with SAX parser as explained <a href="http://www.mkyong.com/java/how-to-read-xml-file-in-java-sax-parser/" rel="nofollow">here</a>, but its not very suitable for me as it throws an exception in case I do not provide a closing tag as in the second xml code I provided. </p>
