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

HOw To I append the Child Element At any node in the Xml Document.

Hello,

I have created the xml Document through the C# application using XmlTextWriter Class,
Which is as bellow,

<?xml version="1.0" encoding="utf-8" ?>
- <!-- Author HarshaL K. Dhote -->

- <Project Location="C:\WorkSpace">
- <Cars>
C:\WorkSpace\Cars
<HONDA>C:\WorkSpace\Cars\HONDA</HONDA>
</Cars>

<Bikes>C:\WorkSpace\Bikes</Bikes>
<Trucks>C:\WorkSpace\Trucks</Trucks>
<busses>C:\WorkSpace\busses</busses>

</Project>

Suppose Now I have to append child to the node Hond, how should I do this programatically,in C#
Feb 1 '08 #1
1 2240
jkmyoung
2,057 Expert 2GB
Since XmlTextWriter is a forward only XML text writer, you must go to the point where you were writing the Honda node, and write the child node at that point.

If you really want to append it anywhere in the document, I suggest one of 2 options:
1. Load the Xml Document into a tree structure. Make the change with DOM oriented functions. (Safe but slow)
2. Hack it up with a script that finds the given node, and then adds in the specified child node appropriately. (Fast but more dangerous.)
Feb 4 '08 #2

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

Similar topics

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...
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...
4
by: patrizio.trinchini | last post by:
Hi all, I'm new to XSLT and maybe my problem have a very trivial answer, but I need an expert that point me in the right direction. What I would obtain is to remove all the elements that have a...
1
by: Daniel Rucareanu | last post by:
Hello, Does anybody knows how can you delete, in just one step, not using a loop, a subset of the child nodes of a given DOM parent node? The subset will be continous, so for example, if the...
7
by: Ward Germonpré | last post by:
Hi, On a html page I have a Table called "resultaattbl", generated using dom- methods and an array of jsobjects. The rows below the columnheader have a class called "normaal". This is the...
1
by: Rajarshi | last post by:
Hi, I'm using ElementTree for some RSS processing. The point where I face a problem is that within an <item></itemI need to add another child node (in addition to <linketc) which is a well-formed...
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: harshaldhote | last post by:
Hello, I have created the xml Document through the C# application using XmlTextWriter Class, Which is as bellow, <?xml version="1.0" encoding="utf-8" ?> - <!-- Author HarshaL K. Dhote --> ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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?
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...

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.