0

如何在此循环中获取 XML 元素的位置?

For Each objNode In objDoc.SelectNodes("//books/book")

 ???

Next

我想要的输出是这样的

1 2 3 4 ....

4

1 回答 1

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
于 2009-05-27T15:01:21.683 回答