title: JAVA - How to remove parent nodes from xml based on child nodes using StAX
body: <p>I processing an xml message in Java and I need to remove the parents from a child node based on the child's attributes. </p>
  
  <pre><code>&lt;xml&gt;
     &lt;A&gt;
       &lt;B&gt;
         &lt;C&gt;
           &lt;E&gt;11&lt;/E&gt;
           &lt;F&gt;12&lt;/F&gt;
         &lt;/C&gt;
      &lt;/B&gt;
      &lt;B&gt;
         &lt;C&gt;
           &lt;E&gt;13&lt;/E&gt;
           &lt;F&gt;14&lt;/F&gt;
        &lt;/C&gt;
      &lt;/B&gt;
    &lt;/A&gt;
  </code></pre>
  
  <p>For example, how to remove Entire B Node if E=13. This would be trivial task with some in-memory approach such as DOM but because of perfomance issues I need to be using StAX wich parses the xml message top bottom. How can I accomplish this using StAX? Thank you so much in advance.</p>