准 html 文本,看起来像:
Simple<br> text <b>simple</b> text simple <BR><BR>text simple text
,我想解析它并创建dom 文档。但是问题在于未封闭的标签,当我尝试这个时:
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
InputSource source = new InputSource(new StringReader(
Document doc = builder.parse(source);
发生错误:org.xml.sax.SAXParseException; The element type "br" must be terminated by the matching end-tag
我不想全部替换<br>
为<br></br>
,任何解决方案或建议?