473,698 Members | 2,841 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

2 New Member
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:\Wo rkSpace">
- <Cars>
C:\WorkSpace\Ca rs
<HONDA>C:\WorkS pace\Cars\HONDA </HONDA>
</Cars>

<Bikes>C:\WorkS pace\Bikes</Bikes>
<Trucks>C:\Work Space\Trucks</Trucks>
<busses>C:\Work Space\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 2263
jkmyoung
2,057 Recognized Expert Top Contributor
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
1880
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 replace the <pre> node in question with a new <pre> node that has the extended content. But the existing content is longish, and it seems to me wasteful to rewrite it all just to have a small amount of text tacked on to the end. Is there a way to...
3
23952
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
2652
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 via a string feed within a web service: <Root> <Product> <File>Order</File> <Origin>OregonOffice</Origin>
4
2919
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 child element with an attribute set at a given value; maybe an example is more self-explaining... Given the following input XML document:
1
2328
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 parent node has 100 nodes, I want to delete nodes 10 through 75, and not nodes 5, 10, 25 etc. I have a reference to the first and the last node in the list that has to be removed. Also it's position in the list, if that helps.
7
2281
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 layout: ... <tr class=normaal> <td><td> <td><a href><img outlook-icon /></a>
1
2603
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 XML document (Chemical Markup Language to be precise). So my code looks like: import cElementTree as ET c = open('x.cml').readlines()
7
3296
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
975
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 --> - <Project Location="C:\WorkSpace"> - <Cars>
0
9170
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8901
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7739
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.