我有这个 hap 代码,它试图从节点的主集合中选择子节点
Dim items As HtmlNodeCollection = doc.DocumentNode.SelectNodes("//channel/item")
For Each item In items
link = item.SelectSingleNode("//link")
title = item.SelectSingleNode("//title")
next
xml是
<rss version="2.0">
<channel>
<title>title title</title>
<link>http://www.link.com</link>
<description>long decription</description>
<item>
<title>title title</title>
<link>http://www.link.com/</link>
<description> description</description>
</item>
<item>
<title>title title</title>
<link>http://www.link.com/</link>
<description> description</description>
</item>
<item>
<title>title title</title>
<link>http://www.link.com/</link>
<description> description</description>
</item>
</channel>
</rss>
但我没有得到每个项目的相应节点标题和项目下的链接。我在哪里弄错了?
我本来可以做的
Dim links As HtmlNodeCollection = doc.DocumentNode.SelectNodes("//channel/item/link")
Dim titles As HtmlNodeCollection = doc.DocumentNode.SelectNodes("//channel/item/title")
但我需要每个项目的链接和标题