title: Using StaX how to read UTF-8 data with &amp; characters?
body: <p>How can I read with Stax all characters from a tag text, even the <code>&amp;amp;</code>?
  I don't have influence on the incoming XML file.</p>
  <p>An example XML file is:</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;Employees&gt;
      &lt;Employee id=&quot;1&quot;&gt;
          &lt;age&gt;22&lt;/age&gt;
          &lt;name&gt;MyName &amp;amp; Team 01/46&lt;/name&gt;
          &lt;gender&gt;Female&lt;/gender&gt;
          &lt;role&gt;Java Developer&lt;/role&gt;
      &lt;/Employee&gt;
      ....
  &lt;/Employees&gt;
  </code></pre>
  <p>Via a number of attempts, from the name only the &quot;MyName&quot; part is read.</p>
  <p>Attempt 1:</p>
  <pre class="lang-java prettyprint-override"><code>Path gpxPath = Paths.get( path);
  XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();
  XMLStreamReader reader;
  reader = xmlInputFactory.createXMLStreamReader( new FileInputStream(gpxPath.toFile()), &quot;UTF-8&quot;);
  ... 
  String name = reader.getText();
  </code></pre>
  <p>Attempt 2:</p>
  <pre class="lang-java prettyprint-override"><code>XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();
  try {
      XMLStreamReader xmlStreamReader = xmlInputFactory.createXMLStreamReader( 
            new DataInputStream(new FileInputStream(fileName)), &quot;UTF-8&quot;);
      ... 
      name = new String( xmlStreamReader.getTextCharacters());
      // or ... 
      name = xmlStreamReader.getText();
  </code></pre>
  <p>How to read the complete name? So, &quot;MyName &amp; Team 01/46&quot;.</p>