【发布时间】:2020-02-10 04:27:49
【问题描述】:
我想在 android 上使用 XMLPullParser 读取这个 xml 文件,但是当涉及到 KeyValues 部分时,它会抛出异常,因为模型中的标签名称不同。 标签是用户指定的,每次 KeyValues 部分都有不同的名称。如何读取这些值?
<Shot>
<ShotGUID>1</ShotGUID>
<Title>aaa</Title>
<Group>bbb</Group>
<SGroup>ccc</SGroup>
<StartTime>00:00:00.00</StartTime>
<EndTime>00:00:00.00</EndTime>
<FileName>110.jpg</FileName>
<Dscp></Dscp>
<KeyValues>
<name>ddd</name>
<family>eee</family>
<date>20.3</date>
</KeyValues>
</Shot>
<Shot>
<ShotGUID>2</ShotGUID>
<Title>qqq</Title>
<Group>www</Group>
<SGroup>rrr</SGroup>
<StartTime>12:00:00.00</StartTime>
<EndTime>13:00:00.00</EndTime>
<FileName>20.jpg</FileName>
<Dscp>hello</Dscp>
<KeyValues>
<email>example@yahoo.com</email>
<index>mmm</index>
<years>562</years>
<factory>nnn</factory>
</KeyValues>
</Shot>
【问题讨论】:
-
请提供一些您目前如何实现的代码。
标签: java android xml-parsing