473,508 Members | 3,688 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Merging XML Documents XmlTextReader against XmlDocument

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.N ame))

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
Nov 12 '05 #1
2 1778
decrypted wrote:
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();


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

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2
decrypted wrote:
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();


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

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #3

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

Similar topics

4
11349
by: Andy Neilson | last post by:
I've run across a strange behaviour with XmlSerializer that I'm unable to explain. I came across this while trying to use XmlSerializer to deserialize from a the details of a SoapException. This...
0
417
by: decrypted | last post by:
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...
2
2613
by: Joris Janssens | last post by:
I'm trying to write a program for validating XHTML 1.1-documents against the XHTML 1.1 DTD (which is actually the same as validating an XML-file) but I always get a "(404) Not found" error. This...
5
9188
by: Geoff Bennett | last post by:
While parsing an XML document, my TextReader instance skips nodes. For example, in this fragment: <Person Sex="Male" FirstHomeBuyer="No" YearsInCurrentProfession="14"> <RelatedEntityRef...
7
4879
by: SQLScott | last post by:
I have a Web Service in which I am trying to pass an XMLDocument as a parameter to one of the methods. I would like to use the XMLTextReader to read the XML but I am getting the following error: ...
1
4412
by: soupaman | last post by:
Im trying to output some filtered xml using the xmlTextReader I know the code and commenting needs cleaned up and eventually plan to add the values to a dataset. currently what this is doing is...
3
1870
by: Patrick | last post by:
I have got 2 XML documents, both of which conform to the same XSD Schema, which define possible optional elements. The 2 XML documents contain 2 disjoint set of XML elements. What is the best,...
1
7004
by: Ryan | last post by:
I was easily able to merge 2 XML files using the guide at http://support.microsoft.com/kb/311530/EN-US/. However, the two XML files may contain duplicate tags. Is there an easy way to merge so that...
17
2665
by: Slonocode | last post by:
Is there any relation between the NodeType and the Text when using the XmlTextReader? The documentation uses select/case while using the xmltextreader. While reader.Read() Select Case...
2
7137
by: josh | last post by:
Hi, I am trying to validate cXML documents against cXML.dtd using the XmlValidatingReader. If I set the XMLValidatingReader's ValidatingType to ValidationType.DTD, I get the following...
0
7332
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,...
1
7058
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
7502
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
5635
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,...
1
5057
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...
0
4715
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...
0
3191
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1565
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
426
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.