sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
Bruno Jouhier's Avatar

Serializing object graph directly to XML document rather than to text


Question posted by: Bruno Jouhier (Guest) on November 12th, 2005 05:08 AM
Is there a way to serialize a graph of objects and get the output as an XML
document, without first serializing to text and then parsing the text (I
know how to do this but I find it really silly and inefficient).

I googled around and from what I found, the answer is NO. Am I missing
something obvious? Is there something new coming in .NET 2.0?

Of course, I'm also interested in the reverse operation (deserializing
directly from XmlDocument rather than from text).

Bruno


3 Answers Posted
Martin Honnen's Avatar
Guest - n/a Posts
#2: Re: Serializing object graph directly to XML document rather than to text



Bruno Jouhier wrote:
[color=blue]
> Is there a way to serialize a graph of objects and get the output as an XML
> document, without first serializing to text and then parsing the text (I
> know how to do this but I find it really silly and inefficient).[/color]

I am not sure what you mean with XML document here, if you serialize you
usually serialize to a stream or file and then you have an XML document
there in that file respectively the file is an XML document.
Or are you talking about System.Xml.XmlDocument and want to convert some
graph of objects into an instance of System.Xml.XmlDocument?


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Bruno Jouhier's Avatar
Guest - n/a Posts
#3: Re: Serializing object graph directly to XML document rather than to text


"Martin Honnen" <mahotrash@yahoo.de> a écrit dans le message de news:
Join Bytes!...[color=blue]
>
>
> Bruno Jouhier wrote:
>[color=green]
>> Is there a way to serialize a graph of objects and get the output as an
>> XML document, without first serializing to text and then parsing the text
>> (I know how to do this but I find it really silly and inefficient).[/color]
>
> I am not sure what you mean with XML document here, if you serialize you
> usually serialize to a stream or file and then you have an XML document
> there in that file respectively the file is an XML document.
> Or are you talking about System.Xml.XmlDocument and want to convert some
> graph of objects into an instance of System.Xml.XmlDocument?[/color]

Of course, I mean an instance of XmlDocument (or XmlElement).
[color=blue]
>
>
> --
>
> Martin Honnen --- MVP XML
> http://JavaScript.FAQTs.com/[/color]


Bruno Jouhier's Avatar
Guest - n/a Posts
#4: Re: Serializing object graph directly to XML document rather than to text

More on this: I needed this because I have a web service with a WebMethod
that returns an XmlNode (this is a generic method that may return different
graphs for different types of objects, I have another method that returns
the associated schema so the client knows what he is dealing with).

I think that I have found my solution:
http://weblogs.asp.net/cazzu/archiv...erformance.aspx

But still, it would be nice if there were a simple API to convert back and
forth between graphs of objects and XmlElement.

Bruno


 
Not the answer you were looking for? Post your question . . .
196,829 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 196,829 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Community Contributors