Groups | Blog | Home
all groups > dotnet xml > june 2004 >

dotnet xml : Merging XML Documents XmlTextReader against XmlDocument


decrypted
6/17/2004 11:29:08 AM
I wrote some code to save layout of forms in my application to an XML File.
One of the forms has a control which can emit its own layout in the form of
XML....so for this controls, I obviously just want to dump the configuration
from the Control right into a sub node of the control node....crude example
<Form>
<Controls>
<Control Name="MyControl1">
<--- insert controls xml output here.
</Control>
</Controls>
</Form>

So....what I did was wrote the output to an XmlTextWriter with a
StringWriter base....then loaded an XmlTextReader with the StringWiter's
StringBuilder.ToString();

Now that I have a filled reader...I am reading through the object and
appending child nodes to the current control node. AKA
controlNode.AppendChild(doc.CreateElement(reader.Name))

And I have additional code to figure out where the child nodes go....but its
kind of messy and I think there is a much easier way to do this....can
anyone point me in the right direction? A bit of a noob on programmatic xml
generation.

Thanks,

dec

Oleg Tkachenko [MVP]
6/20/2004 10:22:47 AM
[quoted text, click to view]

So why don't you write that xml data at the first step - along with
writing to XmlTextWriter?

--
Oleg Tkachenko [XML MVP]
AddThis Social Bookmark Button