从 StackOverflow 原子源获取条目
我觉得再次问这个问题就像个白痴,因为我知道它已经 询问多次次。即使已经提供了答案,我一生也无法让这段代码正常工作,所以我希望通过提供我当前的代码,有人可以帮助我确定哪里出了问题:
Dim RSSReader As New Xml.XmlTextReader("https://stackoverflow.com/feeds")
Dim RSSDoc As New Xml.XmlDocument()
Dim NSMgr As New Xml.XmlNamespaceManager(RSSDoc.NameTable)
NSMgr.AddNamespace("atom", "http://www.w3.org/2005/Atom")
RSSDoc.Load(RSSReader.GetRemainder())
RSSReader.Close()
For Each Node As Xml.XmlNode In RSSDoc.SelectNodes("atom:entry", NSMgr)
AddAtomMessage(Account, Node)
Next
基于上面的代码“AddAtomMessage”方法永远不会被执行,因为 For/Each 行上的“SelectNodes”没有返回任何节点。
I feel like an idiot for asking this question again, as I know it's been asked several times. I cannot for the life of me get this code working even with the answers that have already been provided, so I'm hoping that by offering my current code, someone can help me determine where I'm going wrong:
Dim RSSReader As New Xml.XmlTextReader("https://stackoverflow.com/feeds")
Dim RSSDoc As New Xml.XmlDocument()
Dim NSMgr As New Xml.XmlNamespaceManager(RSSDoc.NameTable)
NSMgr.AddNamespace("atom", "http://www.w3.org/2005/Atom")
RSSDoc.Load(RSSReader.GetRemainder())
RSSReader.Close()
For Each Node As Xml.XmlNode In RSSDoc.SelectNodes("atom:entry", NSMgr)
AddAtomMessage(Account, Node)
Next
Based on the above code the "AddAtomMessage" method never gets executed as no nodes are returns by "SelectNodes" on the For/Each line.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的 XPath 是错误的。您想要
或(越具体越好)
Your XPath is wrong. You want
or (more specific is better)