简体   繁体   English

Android中的Java Xml解析器

[英]Java Xml Parser In Android

I am getting a Response in XML format 我收到XML格式的回应

<item>
<title>
<![CDATA[
28. Februar 2013, FY/Q4 2012 Investoren-Telefonkonferenz
]]>
</title>
<author>
<![CDATA[ BAYER AG - Investorveranstaltungen ]]>
</author>
<pubDate>Thu, 28 Feb 2013 12:00:00 +0100</pubDate>
<description>
<![CDATA[
Rede von Dr. Marijn Dekkers, Vorsitzender des Vorstands der Bayer AG, Investoren-Telefonkonferenz zu den Ergebnissen des Geschaeftsjahres und des 4. Quartals 2012. (Auf...
]]>
</description>
<link>
http://www.webvideo.bayer.com/downloads/9208/9212/12312/file.mp3
</link>
<content:encoded>
<![CDATA[
<p>Rede von Dr. Marijn Dekkers, Vorsitzender des Vorstands der Bayer AG, Investoren-Telefonkonferenz zu den Ergebnissen des Geschaeftsjahres und des 4. Quartals 2012. (Auf Englisch)</p>
]]>
</content:encoded>
<category>ISIN_DE000BAY0017</category>
<category>ISIN_DE000BAY0017</category>
<category>podcast</category>
</item>
<item>
<title>
<![CDATA[
2013-01-30 - Analyst &amp; Investor Conference - Welcome Marc Spieker, Head of Investor Relations
]]>
</title>
<author>
<![CDATA[ E.ON Podcast ]]>
</author>
<pubDate>Wed, 30 Jan 2013 15:00:00 +0100</pubDate>
<description>
<![CDATA[ Analyst &amp; Investor... ]]>
</description>
<link>
http://www.thomson-webcast.net/de/portals/download.mp3?portal_id=315d3fce100b408b41a2c66bb982a367&presentation_id=d43466300a1a8ced8324011b593fb05a&video_id=24ae8f409449411695c0729760646bf7
</link>
<content:encoded>
<![CDATA[ <p>Analyst & Investor Conference</p> ]]>
</content:encoded>
<category>ISIN_DE000ENAG999</category>
<category>ISIN_DE000ENAG999</category>
<category>podcast</category>
</item>

I write a Parser to retrieve data from response . 我编写了一个解析器来从response中检索数据。

But the Problem is .When i test this in 2.1 device , It works as follows, I tested with Android 2.2 ,android 2.2.1 it works fine . 但是问题是。当我在2.1设备上对此进行测试时,它的工作原理如下,我在Android 2.2,Android 2.2.1上进行了测试。 Can any body tell me whats the problem 谁能告诉我是什么问题

    <link>
      http://www.webvideo.bayer.com/downloads/9208/9212/12312/file.mp3
   </link>

I am able retrieve the link correctly But when in another case , I failed 我可以正确检索链接,但是在另一种情况下,我失败了

    <link>
     http://www.thomson-webcast.net/de/portals/download.mp3?portal_id=315d3fce100b408b41a2c66bb982a367&presentation_id=d43466300a1a8ced8324011b593fb05a&video_id=24ae8f409449411695c0729760646bf7
    </link>

When i parse the result is 当我解析结果是

 http://www.thomson-webcast.net/de/portals/download.mp3?portal_id=315d3fce100b408b41a2c66bb982a367

Data after & is missing . &之后的数据丢失。 I saw this only in android 2.1 .Can anybody Suggest me what could be wrong?? 我只在android 2.1中看到过。有人可以建议我怎么了?

Probably the link text should be also in CDATA section, or have the & marks converted to &amp; 链接文本可能也应该在CDATA部分中,或者将&标记转换为&amp;

The &presentation_id... is considered as an (unresolved) XML entity. &presentation_id...被视为(未解析的)XML实体。

Solution 1 (with CDATA ): 解决方案1(使用CDATA ):

<link>
    <![CDATA[http://www.thomson-webcast.net/de/portals/download.mp3?portal_id=315d3fce100b408b41a2c66bb982a367&presentation_id=d43466300a1a8ced8324011b593fb05a&video_id=24ae8f409449411695c0729760646bf7]]>
</link>

Solution 2 with &amp; 溶液2 &amp; :

<link>
    http://www.thomson-webcast.net/de/portals/download.mp3?portal_id=315d3fce100b408b41a2c66bb982a367&amp;presentation_id=d43466300a1a8ced8324011b593fb05a&amp;video_id=24ae8f409449411695c0729760646bf7
</link>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM