Considering I have the following XML file:
<family>
<name gender="Male">
<firstname>Tom</firstname>
<lastname>Smith</lastname>
<phone>111111</phone>
<phone>222222</phone>
</name>
<name gender="Female">
<firstname>Dale</firstname>
<lastname>Smith</lastname>
<phone>111111</phone>
<phone>222222</phone>
</name>
</family>
I'm using an XmlTextReader to parse the XML, my code goes like this:
Dim m_xmlr As XmlTextReader
m_xmlr = New XmlTextReader(InputXML)
m_xmlr.WhitespaceHandling = WhitespaceHandling.None
m_xmlr.Read()
m_xmlr.Read()
While Not m_xmlr.EOF
m_xmlr.Read()
If Not m_xmlr.IsStartElement() Then
Exit While
End If
Dim gender as string = m_xmlr.GetAttribute("gender")
m_xmlr.Read()
Dim FirstName As Array = m_xmlr.ReadElementString("firstname")
Dim LastName As String = m_xmlr.ReadElementString("lastname")
Dim phone As String = m_xmlr.ReadElementString("phone")
End While
m_xmlr.Close()
My question is, how can i get both phone nodes to put in 2 different variables?
PS: I can't modify the xml, and no att can be added to any node.
Thank you in advance.
No comments:
Post a Comment