473,322 Members | 1,352 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

XmlSerializer & external XML document

I get an XmlDocument from an external source.
I want to load it/map it to C# class.

I'm creating classes as I learn about the format. many tag are yet unparsed,
but that seems ok for the XmlSerializer, great!

Now here is my problem.

let say my document conceptually map to classes like that:
public class Foo
{
public string Something;
}
public class Bar
{
public Foo Foo1;
public Foo Foo2;
public List<Foo> ListFoo1;
public List<Foo> ListFoo2;
}

the problem is it's write this way:
<bar>
<foo1>
<something>lalala</something>
</foo1>
<foo2>
<Foo>
<something>lalala</something>
</Foo>
</foo2>
<ListFoo1>
<Foo>
<something>lalala</something>
</Foo>
<Foo>
<something>lalala</something>
</Foo>
<!-- ... etc .. -->
</ListFoo1>
<ListFoo2>
<afoo>
<Foo>
<something>lalala</something>
</Foo>
</afoo>
<!-- ... etc .. -->
</ListFoo2>
</bar>

as you could see. a class / property is some time:
- just tagged with its name <myprop><!-- value --></myprop>
- or 2 tagged, with the class inside <myprop><Foo><!--
value --></Foo></myprop>

kind of similar for the array where it's
- sometimes array of class:
<ListFoo1><Foo><!-- content --></Foo> ...</ListFoo1>
- or some other times there is a named wrapper as in
<ListFoo2><afoo><Foo><!-- content --> </Foo></afoo> .... </ListFoo2>
Fortunately, the behavior is fixed for a given property! (of course)

Now how could I use read/write C# class from/to this kind of XmlDocument
with minimum effort?
what kind of class/attributes/etc should I use?

Thanks for any tips!
Nov 12 '05 #1
1 1228
almost there...
I'm writting my own XmlSerializer.
That will do!

Except maybe performance wise, but it won't be intensive use, will see...

"Lloyd Dupont" <net.galador@ld> wrote in message
news:ux*************@TK2MSFTNGP15.phx.gbl...
I get an XmlDocument from an external source.
I want to load it/map it to C# class.

I'm creating classes as I learn about the format. many tag are yet
unparsed, but that seems ok for the XmlSerializer, great!

Now here is my problem.

let say my document conceptually map to classes like that:
public class Foo
{
public string Something;
}
public class Bar
{
public Foo Foo1;
public Foo Foo2;
public List<Foo> ListFoo1;
public List<Foo> ListFoo2;
}

the problem is it's write this way:
<bar>
<foo1>
<something>lalala</something>
</foo1>
<foo2>
<Foo>
<something>lalala</something>
</Foo>
</foo2>
<ListFoo1>
<Foo>
<something>lalala</something>
</Foo>
<Foo>
<something>lalala</something>
</Foo>
<!-- ... etc .. -->
</ListFoo1>
<ListFoo2>
<afoo>
<Foo>
<something>lalala</something>
</Foo>
</afoo>
<!-- ... etc .. -->
</ListFoo2>
</bar>

as you could see. a class / property is some time:
- just tagged with its name <myprop><!-- value --></myprop>
- or 2 tagged, with the class inside <myprop><Foo><!--
value --></Foo></myprop>

kind of similar for the array where it's
- sometimes array of class:
<ListFoo1><Foo><!-- content --></Foo> ...</ListFoo1>
- or some other times there is a named wrapper as in
<ListFoo2><afoo><Foo><!-- content --> </Foo></afoo> .... </ListFoo2>
Fortunately, the behavior is fixed for a given property! (of course)

Now how could I use read/write C# class from/to this kind of XmlDocument
with minimum effort?
what kind of class/attributes/etc should I use?

Thanks for any tips!

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: rbronson1976 | last post by:
Hi all, I have a very simple page that Firefox has problems with: www.absolutejava.com/testing.htm First of all, this page seems to be perfectly valid XHTML Strict. Both the W3C validator as...
5
by: Stuart Robertson | last post by:
I am trying to find a solution that will allow me to use XmlSerializer to serialize/deserialize a collection of objects where a given object is shared between two or more other objects, and not...
0
by: keith bannister via .NET 247 | last post by:
(Type your message here) -------------------------------- From: keith bannister Hi, I'm new to .net (as of last week) but here goes. I want to serialize/deserialize a file the conforms...
5
by: Keith Bannister | last post by:
I'm new to .net so here goes. I'm tying to deserialize a class that is associated with an XML schema. I created the C# class with xsd.exe as below: xsd.exe /c /n:somenamespace...
12
by: SJD | last post by:
I've just read Christoph Schittko's article on XmlSerializer: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxmlnet/html/trblshtxsd.asp . . . and very informative it is too....
0
by: William Stacey [MVP] | last post by:
Had a method that got some string info from mp3 tags in N files and serializes this class and deserializes at other side. Works ok except sometimes get chars that choke the XmlSerializer. After...
1
by: SteveB | last post by:
I'm porting an application from Apache Xerces to .Net and am having a couple of small problems with deserialization. The XML that I'm reading comes from a variety of sources, and there are two...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.