Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / May 2008

Tip: Looking for answers? Try searching our database.

Help!. Conversion of XML to data objects

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Cairn - 24 May 2008 20:02 GMT
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 - 26 May 2008 08:32 GMT
> 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
[quoted text clipped - 15 lines]
>
> 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/library/system.xml.serialization.ixmlserializabl
e.aspx
.

Signature

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

Cairn - 26 May 2008 10:20 GMT
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.

> > 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
[quoted text clipped - 19 lines]
> See
> http://msdn.microsoft.com/en-us/library/system.xml.serialization.ixmlserializabl
e.aspx
.
Joris van Lier - 26 May 2008 10:58 GMT
> 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/Surrogate_Serialization.aspx

Joris

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.