5

我即将使用 Sencha touch 开发一个应用程序。我现在面临的问题是 Sencha 代码应该读取以下 XML(“data.xml”并显示新闻、文章...),有没有专家可以在这里提供帮助?

    <ns2:categories>
<category>
 <catId>96</catId>
 <title>News</title>
</category>
<category>
 <catId>97</catId>
 <title>Articles</title>
</category>
</ns2:categories>

当我单击新闻作为示例时,应该读取“data_read.xml”中的特定“recordId”元素并显示“origUrl”、“title”、“data”。data_read.xml 如下所示。

<ns2:records>
<record>
<recordId>96</recordId>
<title>123 Lifted</title>
<author>|</author>
<published>2010-01-20T14:36:00.000-08:00</published>
<origUrl>
http://www.abc.com/</origUrl>
<numComments>0</numComments>
<data>
<![CDATA[<p>According to a report on sd asdas das asdasd  asdasd hjjasd .</p>
<p> </p>
<p>This is a landmark vote, and a harbinger of change for this extremely traditional area that also has banned the use of metal r bolt.</p>
<p> </p>
<p>Check out: abc.com and xyz .com for more information.</p>
<p class="modifydate">Last Updated (Wednesday, 20 January 2010 22:36)</p>]]>
</data>
</record>
</ns2:records>

这在 Sencha 中可能吗?

4

2 回答 2

0

我怀疑 XML 阅读器没有正确处理 CDATA(在此处阅读有关 CDATA )解析,但必须稍后再查看。一种可能的替代方法是准备 xml 以删除 CDATA。

于 2013-10-23T19:01:49.570 回答
0

查看 Ext.data.XmlReader 类,看看它是否满足您的需求:

http://dev.sencha.com/deploy/touch/docs/?class=Ext.data.XmlReader

于 2011-01-28T23:42:36.230 回答