Android的解码HTML中的XML文件 [英] Android decoding html in xml file

查看:216
本文介绍了Android的解码HTML中的XML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的软件IM接收是包含像与放一些HTML实体的XML文件;放大器;或什么的。 林全成的XML而不是HTML实体解码。该字符串时,他们遇到一个HTML实体板缺...任何人都可以帮忙吗?我有这样的code居然脱code中的XML ...

In my software im receiving a xml file that is containing some HTML entities like & amp; or whatever. Im successfull decoding the xml but not the HTML entities. The strings are cutted when they meet an html entities... Anybody can help ? I have such code actually to decode the 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实体?

Does anyone know how i can do the same job, decoding the xml as a dom object and also decoding HTML entities ?

其实我的DOM对象是不正确的,因为它含有因为HTML实体被板缺某些字符串...我该怎么办?

Actually my dom object is not correct because its contain some strings that are cutted because of HTML entities... what can i do ?

推荐答案

我觉得国际空间站,因为它检测到撇号作为最后的字符串。我已经成立了一个解决方案。

I think it iss because it detect "'" apostrophe as a final of string. I've founded a solution.

String stringDatosEntrada = new Scanner(urlConnection.getInputStream()).useDelimiter("\\A").next().replaceAll("'","\'").replaceAll("'","\'");

InputStream is = new ByteArrayInputStream(stringDatosEntrada.getBytes());
Document dom = builder.parse(inputStream)

这篇关于Android的解码HTML中的XML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆