By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 924 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

Adding a node to an existing XML file

P: 1
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:


'Create and load the XmlDocument
Dim doc As XmlDocument = New XmlDocument()

'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")

'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
Jan 3 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.