如何解析 XML 文件
我想解析收到的 XML 响应,但找不到解决方案。
有人可以帮我吗?
这是我的回应:
- <member>
<name>AdURLs</name>
- <value>
- <struct>
- <member>
<name>small</name>
- <value>
- <array>
- <data>
- <value>
<string>http://www.jumptap.com/images/cg-windowshade-collapsed.jpg</string>
</value>
- <value>
<string>http://mobilesitelinkexchange.com/images/stories/320x50mobile_standard.gif</string>
</value>
</data>
</array>
</value>
</member>
- <member>
<name>large</name>
- <value>
- <array>
- <data>
- <value>
<string>http://4.bp.blogspot.com/_5pkoVwxuN90/S-RpGWWgshI/AAAAAAAACoU/HlB9I5WOo4g/s400/iphone_jd1003.jpg</string>
</value>
- <value>
<string>http://3.bp.blogspot.com/_5pkoVwxuN90/S_vW6bHZgMI/AAAAAAAACqs/CpQ05gcYtTA/s320/iphone-ps5032.jpg</string>
</value>
</data>
</array>
</value>
</member>
- <member>
<name>medium</name>
- <value>
- <array>
- <data>
- <value>
<string>http://upload.wikimedia.org/wikipedia/en/b/be/Ads-300x250.gif</string>
</value>
- <value>
<string>http://www.wrestling-online.com/images/ads/300x250/nomercy2008.jpg</string>
</value>
</data>
</array>
</value>
</member>
</struct>
</value>
</member>
I want to parse an XML response that I'm getting but I couldn't find a solution for it.
Can anyone help me out?
This is my response:
- <member>
<name>AdURLs</name>
- <value>
- <struct>
- <member>
<name>small</name>
- <value>
- <array>
- <data>
- <value>
<string>http://www.jumptap.com/images/cg-windowshade-collapsed.jpg</string>
</value>
- <value>
<string>http://mobilesitelinkexchange.com/images/stories/320x50mobile_standard.gif</string>
</value>
</data>
</array>
</value>
</member>
- <member>
<name>large</name>
- <value>
- <array>
- <data>
- <value>
<string>http://4.bp.blogspot.com/_5pkoVwxuN90/S-RpGWWgshI/AAAAAAAACoU/HlB9I5WOo4g/s400/iphone_jd1003.jpg</string>
</value>
- <value>
<string>http://3.bp.blogspot.com/_5pkoVwxuN90/S_vW6bHZgMI/AAAAAAAACqs/CpQ05gcYtTA/s320/iphone-ps5032.jpg</string>
</value>
</data>
</array>
</value>
</member>
- <member>
<name>medium</name>
- <value>
- <array>
- <data>
- <value>
<string>http://upload.wikimedia.org/wikipedia/en/b/be/Ads-300x250.gif</string>
</value>
- <value>
<string>http://www.wrestling-online.com/images/ads/300x250/nomercy2008.jpg</string>
</value>
</data>
</array>
</value>
</member>
</struct>
</value>
</member>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我可以向您推荐文章“在 Android 上使用 XML”:http:// www.ibm.com/developerworks/opensource/library/x-android/
它描述了在 Java 中解析 XML 的流行方法:DOM 和 SAX 方法。如果您不需要修改 XML 文档,我建议使用 SAX 方法:它更快且消耗更少的内存。
I can recommend you the article "Working with XML on Android": http://www.ibm.com/developerworks/opensource/library/x-android/
It describes popular ways to parse XML in Java: DOM and SAX approaches. I recommend to use SAX approach if you don't need to modify XML document: it's faster and less memory consuming.