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

Manipulating XML documents

I am trying to insert items to an xml file:

1. Search for the right node where the new item is to be added as a child.
2. Add the new item with its attributes.

I am looking at XPathNavigator and XMLReader but cant find the functions to
do the job. Suggestions are welcome. Thanks in advance.
Nov 16 '05 #1
3 1571
Look at the XmlDocument object

Chris

"Newbie" <Ne****@discussions.microsoft.com> wrote in message
news:FC**********************************@microsof t.com...
I am trying to insert items to an xml file:

1. Search for the right node where the new item is to be added as a child.
2. Add the new item with its attributes.

I am looking at XPathNavigator and XMLReader but cant find the functions
to
do the job. Suggestions are welcome. Thanks in advance.

Nov 16 '05 #2


Newbie wrote:
I am trying to insert items to an xml file:

1. Search for the right node where the new item is to be added as a child.
2. Add the new item with its attributes.

I am looking at XPathNavigator and XMLReader but cant find the functions to
do the job.


Those don't help to manipulate XML, if the XML fits into memory then
XmlDocument in System.Xml is a nice way to read in the whole XML
document into a tree structure of nodes which allows creation and
insertion of new nodes and later saving of the whole tree.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 16 '05 #3
// create the document
XmlDocument xmlDoc = new XmlDocument();
// load the file
xmlDoc.Load(filename);
// goto the node
XmlNode node = xmlDoc.SelectSingleNode("/path/path/node");
// append new node
XmlNode newNode = node.AppendChild(xmlDoc.CreateElement("Element"));
// create attribute
XmlAttribute at =
newNode.Attributes.Append(xmlDoc.CreateAttribute(" test"));
// set value
at.value = "value";
On Fri, 21 Jan 2005 20:03:26 +0100, Martin Honnen <ma*******@yahoo.de>
wrote:


Newbie wrote:
I am trying to insert items to an xml file:

1. Search for the right node where the new item is to be added as a child.
2. Add the new item with its attributes.

I am looking at XPathNavigator and XMLReader but cant find the functions to
do the job.


Those don't help to manipulate XML, if the XML fits into memory then
XmlDocument in System.Xml is a nice way to read in the whole XML
document into a tree structure of nodes which allows creation and
insertion of new nodes and later saving of the whole tree.


Nov 16 '05 #4

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

Similar topics

4
by: Michael J. Astrauskas | last post by:
Does anyone have a function for manipulating GET variables in a URL? I want to be able to modify some parameters without affecting others. An example of what I'm looking for: Let's say the...
3
by: Dave Smithz | last post by:
Hi There, Being quite new to MS-SQL I would like to ask if there is a general opinion of what approach should be taken to storing things like external documents and images in databases. ...
3
by: sal achhala | last post by:
I'm working with java and XML documents in order to search for keywords in a given element name, eg element name 'author' == "jo blogs". The problem is the XML documents are downloaded (this...
2
by: Sune | last post by:
Hi, I'm in the situation that i need to print (to paper) some documents from a database using a website, and i need to manipulate the data on the fly, but my problem is that i don't know how to...
4
by: SP | last post by:
Hi I have a problem with a customer's XML being submitting to me in a non-well-format XML. They said that there are 18 other partners who has been able to tweak the XML to make it work. So I...
6
by: Jim | last post by:
I have a Web application that needs to update a Microsoft Excel spreadsheet for complex calculations, whereby I read the results into a dataset for display. I am accessing my spreadsheet using OLE...
9
by: dgk | last post by:
Is there some built in way to know whether a physical folder path is 'My Documents" for a specific user? I can always use xxx.StartsWith to compare it to the enumeration returned by the Personal...
7
by: Dave | last post by:
Apologies for the newbie question. I have created a vb.net program for my company that is designed to work with Word Templates (about forty of them that we commonly use) that are selected by the...
4
by: Jean-François Michaud | last post by:
Hello, I've been looking at this for a bit now and I don't see what's wrong with the code. Can anybody see a problem with this? Here is an XSLT snippet I use. <xsl:template match="graphic">...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...

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.