.NETGURU
Reading/altering an .xml document
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.sdk.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

Bob Robertson
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
Reply to this message...
 
    
Joe Mayo [C# MVP] (VIP)
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" <Click here to reveal e-mail address> wrote in message
news:ogm_c.53162$nk.31807@okepread05...
[Original message clipped]

Reply to this message...
 
 
System.Xml.XmlDocument
System.Xml.XmlReader
System.Xml.XmlWriter




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification