如何在此循环中获取XML元素的位置?
For Each objNode In objDoc.SelectNodes("//books/book")
???
Next
我想要输出的内容就像是
1 2 3 4 ....
答案 0 :(得分:5)
您可能需要以下内容:
objBooks = objDoc.SelectSingleNode("//books")
Dim pos As Integer = 1
For Each book As XmlNode In objBooks.ChildNodes
Console.Write(pos & " ")
pos = pos + 1
Next