justputitdown
Member
- Joined
- Aug 6, 2006
- Messages
- 7
- Programming Experience
- Beginner
Ive been reading from and xml file and ive also been able to add new data to it but im having trouble modifying the existing data. Below is the code im trying to use. Its not working and im sure its obvious as to why but im a little stuck... Any ideas? No errors are thrown so as far as i can see the data isnt being saved (ie changing the nodes in the nodelist isnt affecting the xml document)... So very stuck though.
VB.NET:
Try
Dim m_xmld As XmlDocument
Dim m_nodelist As XmlNodeList
Dim m_node As XmlNode
m_xmld = New XmlDocument
m_xmld.Load("E:\Domains\www.wanderingshaman.com\data.xml")
m_nodelist = m_xmld.SelectNodes("/twsusers/user")
For Each m_node In m_nodelist
Dim idXMLValue = m_node.ChildNodes.Item(0).InnerText
If CInt(idXMLValue) = m_id Then
m_node.ChildNodes.Item(1).InnerText = fnameIn
m_node.ChildNodes.Item(2).InnerText = lnameIn
m_node.ChildNodes.Item(3).InnerText = usernameIn
m_node.ChildNodes.Item(4).InnerText = passwordIn
m_node.ChildNodes.Item(5).InnerText = emailIn
m_node.ChildNodes.Item(6).InnerText = phoneIn
m_node.ChildNodes.Item(7).InnerText = newsletterIn
m_node.ChildNodes.Item(8).InnerText = adminIn
m_node.ChildNodes.Item(9).InnerText = vegetarianIn
End If
Next
m_xmld.Save("E:\Domains\www.wanderingshaman.com\data.xml")
Catch errorVariable As Exception
'Error trapping
Console.Write(errorVariable.ToString())
End Try