【发布时间】:2014-07-24 06:39:45
【问题描述】:
我有一个要在 java 中解析的 XML 文件,并在谷歌地图中使用该 XML 文件的元素。 下面是我必须解析的xml。
<?xml version = '1.0' encoding = 'UTF-8'?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#">
<channel>
<title/>
<link/>
<description/>
<item>
<title> hang </title>
<description>Total: 291830</description>
<geo:lat>52.0</geo:lat>
<geo:long>-6.0</geo:long>
<dc:subject>category1</dc:subject>
</item>
<item>
<title> system </title>
<description>Total: 78055</description>
<geo:lat>36.66992187</geo:lat>
<geo:long>48.97003173</geo:long>
<dc:subject>category2</dc:subject>
</item>
<item>
<title>chill </title>
<description>Total: 43688</description>
<geo:lat>2.0</geo:lat>
<geo:long>3.8</geo:long>
<dc:subject>category3</dc:subject>
</item>
</channel>
</rss>
顶部的标题和描述与根节点项内的标题和描述发生冲突。谁能帮我解析 xml 并获取标题和描述的值??
【问题讨论】:
-
为什么会有冲突?这看起来像应该是可解析的有效 XML。
-
它与位于顶部和根节点项内的标题和描述标签混淆了。