473,394 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Adding a node to an existing XML file

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
Jan 3 '08 #1
0 1063

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

Similar topics

3
by: sho_nuff | last post by:
Question here: I have been trying to find a way to add existing nested nodes to a tree that already has nodes in it: So, my tree looks like this: -com -foo -goo
3
by: Chua Wen Ching | last post by:
Hi there, I had this tutorial from Microsoft site: http://support.microsoft.com/default.aspx?scid=kb;en-us;815813 I had 1 question. Just say i already serialize a xml file. But next time,...
4
by: Grant | last post by:
Gday, I am using the sample code at: http://support.microsoft.com/default.aspx?scid=kb;en-us;317666 to modify an existing XML document. The XML document looks like the following: ...
1
by: Asha | last post by:
Hello, below is a xml file which I’m working with. I want my result to be like this <group name="grp 4"> <report> <name>MTIS_1</name> </report> <report> <name>MTIS_1</name> </report />
5
by: igotyourdotnet | last post by:
I have a question on atlas: I can create an 'atlas project' and I can add atlas controls fine. but when I try and add an atlas control to an existing asp.net web app I can't, Why? I did notice...
1
by: Bart Steur | last post by:
Hi As a VB6 user I'm unfamiliar with the Treeview control of VB2005. I read it was changed but I have a hard time finding the right help/samples for my problem. In VB6 you had 1 collection,...
2
by: Daljeet Hanspal | last post by:
hi .... i am trying to add a new node to an existing xml file in c# .......... the code is as follows: XmlDocument doc = new XmlDocument(); string filename = @"C:\Documents and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.