Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

Help!. Conversion of XML to data objects

Question posted by: =?Utf-8?B?Q2Fpcm4=?= (Guest) on June 27th, 2008 07:20 PM
I have some XML data which I wish to relate to existing classes, but data
does not map exactly so serialsation will not work, the other consideration
is that some of the XML data will need transposing during the convertion. My
considerations are to either use :-
1.) XSLT initially carry out the converstion so converting some of the data
( space and comma seperated pairs into alist of points) and the go to the
required data objects,
or
2.) using XLINQ in someway to convert from the XML file to the objects.
Does anybody have any advice on the better of the methods, or any
alterantives.
The other consideration is that the XML will be very large with a mixture of
differing objects (the objects are already pre known).

Thanks in advance.
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
Joe Fawcett's Avatar
Joe Fawcett
Guest
n/a Posts
June 27th, 2008
07:20 PM
#2

Re: Help!. Conversion of XML to data objects


"Cairn" <Cairn@discussions.microsoft.comwrote in message
news:E6D01C0A-1965-4A29-ACB3-E08A1EFECC15@microsoft.com...
Quote:
Originally Posted by
I have some XML data which I wish to relate to existing classes, but data
does not map exactly so serialsation will not work, the other
consideration
is that some of the XML data will need transposing during the convertion.
My
considerations are to either use :-
1.) XSLT initially carry out the converstion so converting some of the
data
( space and comma seperated pairs into alist of points) and the go to the
required data objects,
or
2.) using XLINQ in someway to convert from the XML file to the objects.
Does anybody have any advice on the better of the methods, or any
alterantives.
The other consideration is that the XML will be very large with a mixture
of
differing objects (the objects are already pre known).
>
Thanks in advance.

You can still use XML serialisation, you just need to implement the
IXmlSerializable interface and write your own ReadXml method.
See
http://msdn.microsoft.com/en-us/lib...rializable.aspx.

--

Joe Fawcett (MVP - XML)
http://joe.fawcett.name


=?Utf-8?B?Q2Fpcm4=?='s Avatar
=?Utf-8?B?Q2Fpcm4=?=
Guest
n/a Posts
June 27th, 2008
07:20 PM
#3

Re: Help!. Conversion of XML to data objects
Thanks for that, but a number of the existing classes are from the framework,
and I do not want to go through all the code (1000000+) and start renaming
all the classes so that I can add the Ixmlserializable interface to all of
them.


"Joe Fawcett" wrote:
Quote:
Originally Posted by
>
>
"Cairn" <Cairn@discussions.microsoft.comwrote in message
news:E6D01C0A-1965-4A29-ACB3-E08A1EFECC15@microsoft.com...
Quote:
Originally Posted by
I have some XML data which I wish to relate to existing classes, but data
does not map exactly so serialsation will not work, the other
consideration
is that some of the XML data will need transposing during the convertion.
My
considerations are to either use :-
1.) XSLT initially carry out the converstion so converting some of the
data
( space and comma seperated pairs into alist of points) and the go to the
required data objects,
or
2.) using XLINQ in someway to convert from the XML file to the objects.
Does anybody have any advice on the better of the methods, or any
alterantives.
The other consideration is that the XML will be very large with a mixture
of
differing objects (the objects are already pre known).

Thanks in advance.

You can still use XML serialisation, you just need to implement the
IXmlSerializable interface and write your own ReadXml method.
See
http://msdn.microsoft.com/en-us/lib...rializable.aspx.
>
--
>
Joe Fawcett (MVP - XML)
http://joe.fawcett.name
>


Joris van Lier's Avatar
Joris van Lier
Guest
n/a Posts
June 27th, 2008
07:20 PM
#4

Re: Help!. Conversion of XML to data objects
"Cairn" <Cairn@discussions.microsoft.comwrote in message
news:BBACAB1D-0E2F-42B3-A9AE-145CC380581C@microsoft.com...
Quote:
Originally Posted by
Thanks for that, but a number of the existing classes are from the
framework,
and I do not want to go through all the code (1000000+) and start renaming
all the classes so that I can add the Ixmlserializable interface to all of
them.
>



You can use the ISerializationSurrogate interface to delegate the
serialization to another class,
see my post titled "Mapping between schemata while serializing" in this
newsgroup.

How to serialize an object which is not marked as 'Serializable' using a
surrogate.
http://www.codeproject.com/KB/dotne...ialization.aspx

Joris


 
Not the answer you were looking for? Post your question . . .
183,943 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
  • Didn't find the answer you were looking for?
    Post Your Question
  • Top Community Contributors