Connecting Tech Pros Worldwide Forums | Help | Site Map

Help!. Conversion of XML to data objects

=?Utf-8?B?Q2Fpcm4=?=
Guest
 
Posts: n/a
#1: Jun 27 '08
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.

Joe Fawcett
Guest
 
Posts: n/a
#2: Jun 27 '08

re: Help!. Conversion of XML to data objects




"Cairn" <Cairn@discussions.microsoft.comwrote in message
news:E6D01C0A-1965-4A29-ACB3-E08A1EFECC15@microsoft.com...
Quote:
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/libr...ializable.aspx.

--

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

=?Utf-8?B?Q2Fpcm4=?=
Guest
 
Posts: n/a
#3: Jun 27 '08

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:
>
>
"Cairn" <Cairn@discussions.microsoft.comwrote in message
news:E6D01C0A-1965-4A29-ACB3-E08A1EFECC15@microsoft.com...
Quote:
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/libr...ializable.aspx.
>
--
>
Joe Fawcett (MVP - XML)
http://joe.fawcett.name
>
Joris van Lier
Guest
 
Posts: n/a
#4: Jun 27 '08

re: Help!. Conversion of XML to data objects


"Cairn" <Cairn@discussions.microsoft.comwrote in message
news:BBACAB1D-0E2F-42B3-A9AE-145CC380581C@microsoft.com...
Quote:
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/dotnet...alization.aspx

Joris

Closed Thread