473,387 Members | 1,897 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,387 software developers and data experts.

Append Node to an XML

Hi, I would like append a new node with elements in a existing XML file, how
make that?.

For example:

<?xml version="1.0" encoding="utf-8" ?>
- <Configuracion>
- <Estaciones>
<Capa_Trabajo>C:\Temp\point.shp</Capa_Trabajo>
<Estados>C:\Temp\WGS84_region.shp</Estados>
<IndexA>1</IndexA>
<Date>Date=21/03/2007 09:55:52</Date>
</Estaciones>
</Configuracion>

I would like append a node, how make this node?

<Links>
<SiteAontario </SiteA>
<SiteBCanton </SiteB>
</Links>

And my final XML is:

<?xml version="1.0" encoding="utf-8" ?>
- <Configuracion>
- <Estaciones>
<Capa_Trabajo>C:\Temp\point.shp</Capa_Trabajo>
<Estados>C:\Temp\WGS84_region.shp</Estados>
<IndexA>1</IndexA>
<Date>Date=21/03/2007 09:55:52</Date>
</Estaciones>
<Links>
<SiteAontario </SiteA>
<SiteBCanton </SiteB>
</Links>
</Configuracion>

Thanks in advance.

Freddy Coal
Mar 22 '07 #1
2 1831
I'm not sure what net component you are using in your program for the
existing xml, however you can lookup XmlFragment in the help. You create an
XmlFragment from the source document and then AppendChile (or something
similar) to add it to the document.

Rick

Hi, I would like append a new node with elements in a existing XML file,
how make that?.


Mar 23 '07 #2
Freddy Coal wrote:
I would like append a node, how make this node?

<Links>
<SiteAontario </SiteA>
<SiteBCanton </SiteB>
</Links>

And my final XML is:

<?xml version="1.0" encoding="utf-8" ?>
- <Configuracion>
- <Estaciones>
<Capa_Trabajo>C:\Temp\point.shp</Capa_Trabajo>
<Estados>C:\Temp\WGS84_region.shp</Estados>
<IndexA>1</IndexA>
<Date>Date=21/03/2007 09:55:52</Date>
</Estaciones>
<Links>
<SiteAontario </SiteA>
<SiteBCanton </SiteB>
</Links>
</Configuracion>
Use the DOM implementation in the .NET framework, that is
System.Xml.XmlDocument:

Dim XmlDoc As XmlDocument = New XmlDocument()
XmlDoc.Load("file.xml")

Dim Links As XmlElement = XmlDoc.CreateElement("Links")
Dim SiteA As XmlElement = XmlDoc.CreateElement("SiteA")
SiteA.InnerText = "ontario"
Dim SiteB As XmlElement = XmlDoc.CreateElement("SiteB")
SiteB.InnerText = "Canton"
Links.AppendChild(SiteA)
Links.AppendChild(SiteB)

XmlDoc.DocumentElement.AppendChild(Links)

XmlDoc.Save("file.xml")
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Mar 23 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: fremenusul | last post by:
I orginally asked this question on friday, and made some progress, but now I am getting an error. What is the type of xmlProductName (check the runtime type in the debugger)? The debug output...
3
by: J Krugman | last post by:
This question refers to the DOM. I would like to dynamically append some small amount of text to the all-text content of a <pre> node. I suppose that I could extract the existing content, and...
2
by: Scott | last post by:
hi friend's, i m new in both things php and in this group. but i have some basic knowledge of php and DOM in php. here is my problem, i have one textfield for add a new main node (not main like:...
3
by: Jonathan Buckland | last post by:
Can someone give me an example how to append data without having to load the complete XML file. Is this possible? Jonathan
10
by: Rich Wallace | last post by:
I'm sure there's a very weasy way to do this, I've been running hard and fast on several things at once and just may be at the point of overthinking this... I receive an incoming XML document...
3
by: David Elliott | last post by:
I wrote an application to scrape a database and create an XSD file which will be annotated by a map file in order to create a Typed DataSet. I was wondering if I could do the annotation using...
4
by: glbdev | last post by:
Hi, I posted this in "microsoft.public.xml.msxml-webrelease" but now realize it should probably have been in the ASP group. Sorry if that causes any problems. I have an XML document like:...
7
by: vunet.us | last post by:
I cannot append a node from XML into the HTML dom (textarea field) in IE. But I can for the text input html elements! Is anyone aware of this and what is the possible solution? Thanks.
1
by: Aswanth | last post by:
I'm Using Asp.Net with C#.. & Using XML Files.. Please check this.. <Page_Details> <Page="HomePage.aspx" Time="10:30:20:32636" Type="S" ID = "1" Category_ID="41" /> <Page="HomePage.aspx"...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.