Java - convert named html entities to numbered xml entities

Annouseseency

New Member
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. This is the basic idea illustrated via test:\[code\]@Testpublic void testEvalHtmlEntitiesToXmlEntities() { String input = "<a href=http://stackoverflow.com/"test.html\">link&nbsp;</a>"; String expected = "<a href=http://stackoverflow.com/"test.html\">link </a>"; String actual = SomeUtil.eval(input); Assert.assertEquals(expected, actual);}\[/code\]Is anyone aware of a Class that provides this functionality? I can write a regex to iterate through non element matches and do:\[code\]xlmString += StringEscapeUtils.escapeXml(StringEscapeUtils.unescapeHtml(htmlString));\[/code\]but hoped there is an easier way or a Class that already provides this.
 
Back
Top