title: Java - convert named html entities to numbered xml entities
body: <p>I'm looking to convert an html block that contains html named entities to an xml compliant block that uses numbered xml entities while leaving all html tag elements in place. </p>
  
  <p>This is the basic idea illustrated via test:</p>
  
  <pre><code>@Test
  public void testEvalHtmlEntitiesToXmlEntities() {
      String input = "&lt;a href=\"test.html\"&gt;link&amp;nbsp;&lt;/a&gt;";
      String expected = "&lt;a href=\"test.html\"&gt;link&amp;#160;&lt;/a&gt;";
      String actual = SomeUtil.eval(input);
      Assert.assertEquals(expected, actual);
  }
  </code></pre>
  
  <p>Is anyone aware of a Class that provides this functionality? I can write a regex to iterate through non element matches and do:</p>
  
  <pre><code>xlmString += StringEscapeUtils.escapeXml(StringEscapeUtils.unescapeHtml(htmlString));
  </code></pre>
  
  <p>but hoped there is an easier way or a Class that already provides this.</p>