1
我正在嘗試從傳遞給我的方法的文件路徑中讀取XML節點。VB - 使用XPath讀取XML的問題
Public Function ReadXMLForIsite(xmlFileName As String)
Dim IsitePath As String
Dim doc As New XPathDocument(xmlFileName)
Dim nav As XPathNavigator
Dim iter As XPathNodeIterator
nav = doc.CreateNavigator
iter = nav.Select("GovTalkMessage/Header") 'Node name
'Loop through the records in that node
While iter.MoveNext
Dim lstNav As XPathNavigator
'Get the data we need from the node
Dim iterNews As XPathNodeIterator
lstNav = iter.Current
iterNews = lstNav.SelectDescendants(XPathNodeType.Element, False)
'Loop through the child nodes
While iterNews.MoveNext
Debug.WriteLine(iterNews.Current.Name & ": " & iterNews.Current.Value)
End While
End While
Return IsitePath
End Function
每次我運行此方法(即使使用不同的節點名稱)變量「ITER」指出「調試器顯示代理是一種類型的,不能用作表達式」。這發生在while語句之前,因此不會進入。任何幫助將不勝感激。謝謝!
雅各布和盧克...嗯! – Virus