Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Append to a file using XML Serialization? Easy way to do this?

From: RayLopez99 <raylopez88@-----.--->
To: NULL
Date: 7/20/2009 7:56:00 AM
On Jul 20, 5:39=A0am, Martin Honnen <mahotr...@yahoo.de> wrote:
>
> The .NET framework allows you to create an XML fragment by setting
> =A0 =A0settings.ConformanceLevel =3D ConformanceLevel.Fragment;
> on your XmlWriterSettings variable. That way you should be able to write
> out serveral DecoratedPerson elements. You should however be aware that
> you can't read the generated XML with XmlDocument or XDocument as these
> implement the W3C specification for well-formed XML documents to have
> exactly one root element that contains all other elements.
> XmlReader on the other hand can also be set in "fragment mode" with an
> XmlReaderSettings instance and the same ConformanceLevel setting.
>

I thank you for your time.  I am able to generate fragments, but like
you say they miss the "exactly one root element".

Can you post, in pseudo-code or words, how to generate a root element
programically once you have nodes (fragments)?

Let's say you have these node fragments:

<Person>
<FirstName> joe </FirstName>
<LastName> smith </LastName>
</Person>

<Person>
<FirstName> Sam </FirstName>
<LastName> Miller </LastName>
</Person>

In one file, now how can you add a root element in an easy way?

Such as

<?xml version=3D"1.0" ?>
<MyRootElementHere>

// above 2 nodes go here

</MyRootElementHere>

I can do this the "hard way" by mechanically inserting text into
another text file, but I'm wondering if there's a quick way to convert
fragments into well formed XML documents (there should be--this must
be a reoccuring common problem).

Unless there is an easy way to do this, I am going back to using DOM
and "TextWriter", etc, node by node, which at least I am able to form
well formed XML documents (but it's tedious to do).

RL


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent