Well Xml(Text)Reader used with only the Read method is kind of a low level API that gives you a lot of different nodes, you will get element nodes, text nodes, and end element nodes the way you have set up your code.
Below I show some
VB.NET 2005 sample that reads out the text contents of all elements at Depth 1, that might more likely what you want to achieve:
Code:
Using reader As XmlReader = XmlReader.Create("..\..\XMLFile1.xml")
While reader.Read()
If reader.NodeType = XmlNodeType.Element And reader.Depth = 1 Then
Console.WriteLine("Element with name ""{0}"" has contents ""{1}""", reader.Name, reader.ReadString())
End If
End While
End Using
Output with your sample XML is as follows:
Code:
Element with name "ProjectTitle" has contents "mike' s project title"
Element with name "ProjectOutline" has contents "this is a brief project outline"
Element with name "ProjectNo" has contents "124321"
Element with name "ProjectLeader" has contents "joe bloggs"
Element with name "ProjectDuration" has contents "12.00000000"
Element with name "EndDate" has contents "2008-04-10"
Element with name "StartDate" has contents "2008-02-04"
Element with name "drpOrganisation" has contents "Dunmore Ltd"
Element with name "drpPartner" has contents "Fishermans Co-op"
Element with name "FDDteam" has contents "Environment Group 9"
My sample writes to the console, in an ASP.NET application you might want to output the data in a control or send it directly to the Response.