我目前正在尝试从传递给我的方法的文件路径中读取 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 语句之前,因此不会进入。任何帮助将不胜感激。谢谢!