xml命名空间-vb.net XmlDocument.SelectSingleNode和xmlNamespace问题



我正试图让这段代码正常工作,但不知何故没有得到内容

我的代码

Dim m_xmld As XmlDocument
    Dim m_nodelist As XmlNodeList
    Dim m_node As XmlNode
    'Create the XML Document
    m_xmld = New XmlDocument()
    'Load the Xml file
    m_xmld.Load("http://feeds.thescore.com/nfl.rss")
    'Get the list of name nodes 
    m_nodelist = m_xmld.SelectNodes("/rss/channel/item")
    Dim content As XmlNamespaceManager = New XmlNamespaceManager(m_xmld.NameTable)
    content.AddNamespace("content", "http://schemas.xmlsoap.org/soap/envelope/")
    'Loop through the nodes
    For Each m_node In m_nodelist
        If Not m_node.SelectSingleNode("content:encoded",content) Is Nothing AndAlso Len(m_node.SelectSingleNode("content:encoded",content).InnerText) > 0 Then 
            response.Write(m_node.SelectSingleNode("content:encoded",content))
            response.Flush()
        end if
    Next

有人能帮帮我吗?

我这样做了,可以看到所有的内容节点,它们看起来都是html。

Imports <xmlns:atom="http://www.w3.org/2005/Atom">
Imports <xmlns:content="http://purl.org/rss/1.0/modules/content/">
Imports <xmlns:dc="http://purl.org/dc/elements/1.1/">
Imports <xmlns:georss="http://www.georss.org/georss">
Imports <xmlns:media="http://search.yahoo.com/mrss/">
Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim xe As XElement = XElement.Load("http://feeds.thescore.com/nfl.rss")
        Dim ie As IEnumerable(Of XElement) = xe...<content:encoded>
        For Each c As XElement In ie
            Debug.WriteLine(c.Value)
        Next
    End Sub

End Class

我用不同的方法管理,我首先用webClient导入数据,用替换,并像一个魅力一样工作

最新更新