title: Dynamically reading raw XML elements as text in Java
body: <p>Assuming an XML file with unknown structure (i.e., unknown element and attribute names), like</p>
  
  <pre><code>&lt;RootElement&gt;
     &lt;Level 1 ...&gt;
          &lt;Level 2 ...&gt;
              ...
          &lt;/Level 2&gt;
          &lt;Level 2 ...&gt;
              ...
          &lt;/Level 2&gt;
      &lt;/Level 1&gt;
      &lt;Level 1 ...&gt;
          &lt;Level 2 ...&gt;
              ...
          &lt;/Level 2&gt;
          &lt;Level 2 ...&gt;
              ...
          &lt;/Level 2&gt;
      &lt;/Level 1&gt;
  &lt;/RootElement&gt;
  </code></pre>
  
  <p>Is there any way using StAX to get the full <strong>raw text</strong> of each element?</p>
  
  <p>At least, how can this be done for the first level, i.e. in the above example (ignoring pretty printing) how can we read the following 2 strings in a Java String variable:</p>
  
  <pre><code>"&lt;Level 1 ...&gt;&lt;Level 2...&gt;...&lt;/Level 2&gt;&lt;/Level 1&gt;"
  </code></pre>
  
  <p>and</p>
  
  <pre><code>"&lt;Level 1 ...&gt;&lt;Level 2...&gt;...&lt;/Level 2&gt;&lt;/Level 1&gt;"
  </code></pre>