title: How to get Embeded/nested XML from a big XML file using SAX parser
body: <p>We are performing some operations on embedded/Nested XML.I am using SAXParser to parse the entire XML file.I want to get the entire nested XML with tags and value.For example my XML looks like.</p>
  
  <p>I want entire XML within the <code>&lt;ANY_ELEMENT&gt;</code>.....&lt;<code>/ANY-ELEMENT&gt;</code> tag.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
              &lt;x:xMessage xmlns:x="http://www.connecture.com/integration/x" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                              xsi:schemaLocation="http://www.connecture.com/integration/x xMessageWrapper.xsd
                  "&gt;
                  &lt;x:xMessageHeader&gt;
                      &lt;Version&gt;850&lt;/Version&gt;
                      &lt;Source&gt;Source&lt;/Source&gt;
                      &lt;Target&gt;target&lt;/Target&gt;
                      &lt;Timestamp&gt;2013-12-31T12:00:00&lt;/Timestamp&gt;
                      &lt;RequestID&gt;123456&lt;/RequestID&gt;
                      &lt;ResponseID&gt;54321&lt;/ResponseID&gt;
                      &lt;Priority&gt;3&lt;/Priority&gt;
                      &lt;Username&gt;Deepak&lt;/Username&gt;
                      &lt;Password&gt;Kumar&lt;/Password&gt;
                  &lt;/x:xMessageHeader&gt;
                  &lt;x:xMessageBody&gt;
                      &lt;ANY-ELEMENT&gt;
                          &lt;xEnveloped_834A1 xsi:schemaLocation="....." xmlns="......."
                              ..........................
                      ..........................
                              some Complex XML
                          ..........................
                          ..........................
                          ..........................
  
                      &lt;/ANY-ELEMENT&gt;
  
                   &lt;/x:XMessageBody&gt;
          &lt;/x:XMessage&gt;
  </code></pre>
  
  <p><strong>Handler class Sample code:</strong></p>
  
  <pre><code>public class MessageWrapperHandler extends DefaultHandler {
  
  
      private boolean bActualMessage = false;
      private String actualMessage = null;
      private long lengthActualMessage=0;
  
  
  
      public void startElement(String uri, String localName, String qName, Attributes attributes) {
  
        if (qName.equalsIgnoreCase("ANY-ELEMENT")) {
              bActualMessage = true;
              //lengthActualMessage=How to know the length of Child XML
          }
      }
    public void characters(char ch[], int start, int length) {
  
           if (bActualMessage) {
              actualMessage = new String(ch, start, length);
              //trying to get embedded XML
              bActualMessage = false;
          }
      }
  
  }
  </code></pre>
  
  <p>But since next element after  is XML content so giving me nothing.SO How to achieve it.
  <strong>EDIT:</strong> You are free to modify XML after <code>&lt;ANY-ELEMENT&gt;</code> like adding contents into <code>CDATA</code></p>