vb.net XML For loop



I have code for reading XML elements like this:



Dim xmlRoot As XElement = XDocument.Load("x:\books.xml").Root

For Each book As XElement In xmlRoot.<book>
Debug.WriteLine(book.<title>.Value)
Debug.WriteLine(book.<author>.Value)
Debug.WriteLine(book.<year>.Value)
Debug.WriteLine(book.<price>.Value)
Next


What I want now is, how to display only 10 elements. Now I have displayed all xml elements but I need only first 10. Tried with few For loop combinations but didn't get it work.


Thanks


No comments:

Post a Comment