472,968 Members | 1,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,968 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 1213
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.