473,326 Members | 2,061 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,326 software developers and data experts.

Reading/altering an .xml document

Hey guys -

I'm fairly new to .NET and am trying to do the following: Read in one
..xml document, selectively remove and/or change certain nodes within it,
then save the results in a second document. For instance, if I have:

<a name="a">
<b name="b" miscattr="blah">
<c name="c1"/>
<c name="c2"/>
</b>
</a>

I want to convert that into:

<a name="a">
<b name="b" miscattr="blah">
<c name="c3"/>
<c name="c4"/>
<c name="c5"/>
</b>
</a>

Right now, I am using an XmlReader.Read() loop to parse through the
first file. I WAS going to use XmlWriter.WriteNode(XmlReader,...) -
unfortunately, it copies all child nodes (when it hits the 'a'
everything within 'a' is copied as well). What
classes/methods/techniques would you guys recommend for solving this
problem?

Thanks,

Bob
Nov 16 '05 #1
1 1160
Hi Bob,

Check out XmlDocument. The tradeoff here will be that XmlDocument stores
everything in memory, which is good if your document isn't too large. The
benefits are that it is much more flexible. The XmlReader and XmlWriter
work with streams, which is good because you can work on extremely large
documents without wasting memory. However, because they are forward-only
streams, you have less flexibility.

Joe
--
Joe Mayo, Author/Instructor
Need C#/.NET training?
visit www.mayosoftware.com
C# Tutorial - www.csharp-station.com

"Bob Robertson" <br********@aol.com> wrote in message
news:ogm_c.53162$nk.31807@okepread05...
Hey guys -

I'm fairly new to .NET and am trying to do the following: Read in one
.xml document, selectively remove and/or change certain nodes within it,
then save the results in a second document. For instance, if I have:

<a name="a">
<b name="b" miscattr="blah">
<c name="c1"/>
<c name="c2"/>
</b>
</a>

I want to convert that into:

<a name="a">
<b name="b" miscattr="blah">
<c name="c3"/>
<c name="c4"/>
<c name="c5"/>
</b>
</a>

Right now, I am using an XmlReader.Read() loop to parse through the
first file. I WAS going to use XmlWriter.WriteNode(XmlReader,...) -
unfortunately, it copies all child nodes (when it hits the 'a'
everything within 'a' is copied as well). What
classes/methods/techniques would you guys recommend for solving this
problem?

Thanks,

Bob

Nov 16 '05 #2

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

Similar topics

1
by: Randell D. | last post by:
HELP! I am determined to stick with this... I'm getting there... for those who haven't read my earlier posts, I'm createing what should be a simple function that I can call to check that...
27
by: C Gillespie | last post by:
Dear All, Hopefully I have a simple problem. Basically, I just want to alter some text with JS. Here is some of my test code: <snip> <script type="text/javascript"> var tmp='a';
1
by: Bob Robertson | last post by:
Hey guys - I'm fairly new to .NET and am trying to do the following: Read in one ..xml document, selectively remove and/or change certain nodes within it, then save the results in a second...
3
by: Scott | last post by:
I am trying to alter the ForeColor of a TextBox object so that parts of the displayed text are written in various colors. For example, when writing to the TextBox I wish to display parts of the...
1
by: SteveB | last post by:
I'm porting an application from Apache Xerces to .Net and am having a couple of small problems with deserialization. The XML that I'm reading comes from a variety of sources, and there are two...
9
by: jason.hau | last post by:
Is there any way to alter this? I am aware that it's read only. Essentially the problem is that I have a webcontrol that dynamically creates a textbox and a requiredfieldvalidator control with the...
9
by: JimmyKoolPantz | last post by:
IDE: Visual Studio 2005 Language: VB.NET Fox Pro Driver Version: 9.0.0.3504 Problem: I currently have a problem altering a DBF file. I do not get any syntax errors when running the program. ...
4
by: daniel.bron | last post by:
Hello, Given a XML document, an XPath to a leaf node, and a string value, what is the briefest XSLT transform to change that node's value to the given string? The node is unique, unrepeated,...
1
by: zufie | last post by:
Hi, I want to specifying a foreign key by altering a table. First, I create an ORDERS table without specifying a foreign key. Here is my code: CREATE TABLE ORDERS (Order_ID integer,...
16
by: Jm.GlezdeRueda | last post by:
Hi all, Im trying to read a 24bit bmp with fread, and i have some problems.. I want to read the whole structure in one time, but i dont know why, it only reads the first member well.. I have...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.