XmlTextReader where am i going wrong?

Currymunch

Member
Joined
Jan 21, 2008
Messages
13
Programming Experience
Beginner
references : http://vbcity.com/forums/topic.asp?tid=98144

the xml file looks like:

HTML:
<?xml version="1.0"?>
<Spys>
         <Spy>
                  <First Name>Joe</First Name>
                  <Surname>Bloggs</Surname>
                  <Code Name>JB</Code Name>
                  <Age>24</Age>
         </Spy>
         <Spy>
                  <First Name>Joe1</First Name>
                  <Surname>Bloggs1</Surname>
                  <Code Name>JB1</Code Name>
                  <Age>26</Age>
         </Spy>
</Spys>

For the life of me i cannot read through the values of the XML file, thus far i have (courtesy of reference), it returns "Spys" and "Spy"

'**************************************
responds to a click
VB.NET:
Dim xmlpath As String = "C:\Users\AngryBowser\Desktop\Uni\Myspy - Draft 2\bin\SpyList.xml"
Dim xmlReader As New XmlTextReader(xmlpath)

        Try

            While (xmlReader.Read)
                Select Case xmlReader.NodeType
                    Case XmlNodeType.Element
                        MsgBox("Element Name: " & xmlReader.Name)
                    Case XmlNodeType.Text
                        MsgBox("Element Value: " & xmlReader.Value())
                End Select
            End While

        Catch ex As Exception
        End Try

        xmlReader.Close()
'***************************************

Been bashing my head against this for what seems like eternity and it's the last piece of the puzzle for me, could anyone draw up an example of how to get the values of the child nodes from each child parent node. This is driving me mad now as I have no doubts that its pretty cake but it simply is not clicking.
 
Last edited by a moderator:
Your Xml is not valid, Xml element names cannot contain spaces.
 
Back
Top