Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/225.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android:读取包含HTML代码的XML文件_Android_Html_Rss_Cdata_Rss Reader - Fatal编程技术网

Android:读取包含HTML代码的XML文件

Android:读取包含HTML代码的XML文件,android,html,rss,cdata,rss-reader,Android,Html,Rss,Cdata,Rss Reader,大家好; 我有一个xml文件“feed.xml”,格式如下: <rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"> <channel> <item> <cache>0</cache> <id>v_article_16337.html</id> <article_id>16337</article_id> <ty

大家好; 我有一个xml文件“feed.xml”,格式如下:

<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
<channel>
<item>
<cache>0</cache>
<id>v_article_16337.html</id>
<article_id>16337</article_id>
<type>article</type>
<img>
http://website.com/main/image.jpg
</img>
<filename>
http://website.com/other/image.jpg
</filename>
<origine_filename>
http://website.com/image.jpg
</origine_filename>
<title>
<![CDATA[
Here plain text
]]>
</title>

<datePub>
<![CDATA[ 28.03.2013 | 08h00 | ]]>
</datePub>
<nbrComment>0</nbrComment>
<lastComment>
<![CDATA[ ]]>
</lastComment>
<theSameCategorie>
<![CDATA[
Here HTML Code
]]>
</theSameCategorie>
<description>
<![CDATA[
Here plain text
]]>
</description>
<content>
<![CDATA[

Here html code
]]>
</content>
</item>
</channel>
</rss>

0
v_article_16337.html
16337
文章
http://website.com/main/image.jpg
http://website.com/other/image.jpg
http://website.com/image.jpg
0
我需要如何解析所有这些信息并将其保存在本地文件中,以便以后在没有可用的internet连接时观看,我发现如果使用CDATA标记,该值将被忽略!
谢谢

您必须循环遍历所有子项(无论有多少子项)并连接每个子项的值以获得完整结果,或者如果区分纯文本和CDATA中的文本并不重要,则首先在document builder factory上设置合并属性:

DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
docFactory.setCoalescing(true);