我有一个XML部分,看起来像这样:
<entry>
<id>tag:example.com,2005:Release/343597</id>
<published>2012-04-10T11:29:19Z</published>
<updated>2012-04-10T12:04:41Z</updated>
<link type="text/html" href="http://example.com/projects/example1" rel="alternate"/>
<title>example1</title>
</entry>
我需要从这个块中抓取链接http://example.com/projects/example1
。我不确定如何实现。我使用以下代码来获取项目的标题:
String title1 = children.item(9).getFirstChild().getNodeValue();
这里的children
是<entry> </entry>
块的getChildNodes()
对象。但是,在类似的方式中尝试获取<link>
节点值时,我一直收到NullPointerExceptions
。我发现<link>
节点的XML代码不同,我不确定它的值是什么...请给予建议!