Editing Multiple Nodes in a XML File - How?
Alright, I decided instead of Serialization or Access, I'm going be using XML files.
Now, I have them properly adding and editing, but I see theirs a property .SelectNodes( )
How do I use this ? I did a quick Google Search, couldn't find much. Here's the current Code I'm using to Edit my Document.
vb Code:
Public Sub EditClasses()
With frmClassEdit
Dim xmlDoc As New XmlDocument
xmlDoc.Load(Application.StartupPath & "\Data\" & .cmbClassSelection.SelectedItem.ToString & ".xml")
Dim xmlnod As XmlNode
xmlnod = xmlDoc.DocumentElement.SelectSingleNode("Classes/ClassName")
xmlnod.InnerText = .txtClassName.Text
xmlnod = xmlDoc.DocumentElement.SelectSingleNode("Classes/ClassCode")
xmlnod.InnerText = .txtClassCode.Text
xmlnod = xmlDoc.DocumentElement.SelectSingleNode("Classes/ClassRoom")
xmlnod.InnerText = .txtClassRoom.Text
xmlnod = xmlDoc.DocumentElement.SelectSingleNode("Classes/Grade")
xmlnod.InnerText = .numGrade.Value
xmlDoc.Save(Application.StartupPath & "\Data\" & .txtClassCode.Text & ".xml")
xmlDoc.RemoveAll()
End With
End Sub
Re: Editing Multiple Nodes in a XML File - How?
You make a string query and it will select nodes matching your criteria and return a System.Xml.XmlNodeList as illustrated here:
SelectNodes XPath Queries
One function is you can mass update stuff based on parameters you define.
Re: Editing Multiple Nodes in a XML File - How?
Hey,
Both SelectNodes and SelectSingleNode accept an XPath Query which identifies which node, or collection of nodes that you want to isolate.
There are a number of posts in this forum that discuss this, and you can check the link in my signature for more details on XPath.
Hope that helps!!
Gary