I've just begun learning XML and XPATH, so I'm currently at a very beginner level. I have an existing XML file that I would like to add an additional node to before saving it to another variable. The code looks like this:
Code:
'Create and load the XmlDocument
Dim doc As XmlDocument = New XmlDocument()
doc.LoadXml(lsum.XmlDoc.InnerXml)
'Create new node
Dim regionElement As XmlElement = doc.CreateElement("Region")
regionElement.InnerText = aryFolders(i).ToString.Trim()
'Add node to proper location
Dim node As XmlNode = doc.SelectSingleNode("/Collection/Content/Html/root")
node.AppendChild(regionElement)
'Insert new element into original XML file
xString &= doc.InnerXml.ToString
Now, I've managed to add the new node, but I can't seem to get it to go where I'd like it to within the XML structure. I'm sure it's something simple that I'm overlooking. Could someone please help me? Thanks!
Reply With Quote