在我的软件中,我收到一个 xml 文件,其中包含一些 HTML 实体,例如 & amp; 管他呢。我成功地解码了 xml 但不是 HTML 实体。当遇到一个 html 实体时,字符串会被切断......有人可以帮忙吗?我实际上有这样的代码来解码 xml...
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
InputStream inputStream = entity.getContent();
Document dom = builder.parse(inputStream);
inputStream.close();
Element racine = dom.getDocumentElement();
NodeList nodeLst=racine.getElementsByTagName("product");
有谁知道我如何做同样的工作,将 xml 解码为 dom 对象并解码 HTML 实体?
实际上我的 dom 对象是不正确的,因为它包含一些由于 HTML 实体而被剪切的字符串......我该怎么办?