如何在一个ListView显示的数据,一旦你解析嵌套的标签的XML? [英] How to display data in a ListView once you parse the XML with nested tag?

查看:140
本文介绍了如何在一个ListView显示的数据,一旦你解析嵌套的标签的XML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的XML文件,该文件是这样的:

I have the XML file which is like this:

<activities>
<activity>
    <filename>http://www.someurl.com/documentSetting/members/0/701/66/videos/521/521.mp4</filename>
    <thumbnail>http://www.someurl.com/documentSetting/members/0/701/66/videos/521/521_120x90.jpg</thumbnail>
    <id>521</id>
    <is_private>0</is_private>
    <comments>
        <comment>
            <id>111</id>
            <body>Good video</body>
            <member_id>oo7</member_id>
            <profile_image>http://www.someurl.com/images/avatar/default_male_qlone.png</profile_image>
        </comment>
        <comment>
            <id>222</id>
            <body>nice video</body>
            <member_id>123</member_id>
            <profile_image>http://www.someurl.com/images/avatar/default_male_qlone.png</profile_image>
        </comment>
        <comment>
            <id>333</id>
            <body>gotcha!!!</body>
            <member_id>11</member_id>
            <profile_image>http://www.someurl.com/images/avatar/default_male_qlone.png</profile_image>
        </comment>
</activity>

<activity>
    <filename>http://www.someurl.com/documentSetting/members/0/701/66/videos/521/521.mp4</filename>
    <thumbnail>http://www.someurl.com/documentSetting/members/0/701/66/videos/521/521_120x90.jpg</thumbnail>
    <id>522</id>
    <is_private>0</is_private>
    <comments>
        <comment>
            <id>101</id>
            <body>aaa</body>
            <member_id>oo7</member_id>
            <profile_image>http://www.someurl.com/images/avatar/default_male_qlone.png</profile_image>
        </comment>
        <comment>
            <id>222</id>
            <body>bbb</body>
            <member_id>123</member_id>
            <profile_image>http://www.someurl.com/images/avatar/default_male_qlone.png</profile_image>
        </comment>
        <comment>
            <id>333</id>
            <body>ccc</body>
            <member_id>11</member_id>
            <profile_image>http://www.someurl.com/images/avatar/default_male_qlone.png</profile_image>
        </comment>
</activity>

现在我要分析此XML文件并显示它像这样ListView中:::

Now i want to parse this XML file and Display it like this in ListView :::

考虑文件名标记作为状态::

Consider filename tag as Status ::

状态1:

        Comment 1
        Comment 2   
        Comment 3 
        Comment 4

状态2:

        Comment 1
        Comment 2   
        Comment 3 

假设第一个活动有4个注释为嵌套的标签和次活动在他的注释标签的3注释。

Suppose the first activity has 4 comment as a nested tag and second activity has the 3 comment in his comment tag.

如何做到这一点?

推荐答案

尝试使用它是由机器人提供的SAX解析器。

Try using SAX Parser which is provided by Android.

下面是一个很好的例如 使用SAX解析器方法如何ü可以解析的XML文件。

Here's a good example how can u parse an XML file using SAX Parser method.

这篇关于如何在一个ListView显示的数据,一旦你解析嵌套的标签的XML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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