473,405 Members | 2,445 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,405 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 12 '05 #1
1 1467
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 12 '05 #2

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

Similar topics

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...
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. ...
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
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:
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,...
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...
0
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...
0
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...
0
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,...
0
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...

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.