XmlSerialization (other questions)

L

Lloyd Dupont

I get an XmlDocument (from an external source) which is rougly like that

<TopElement>
<SomeElement/>
<ListA>
<aA>
<A><!-- A content --></A>
</aA>
<aA>
<A><!-- A content --></A>
</aA>
<!-- other As.... -->
<ListA>
</TopElement>

I would like to map this to this document to something like
public class TopElement
{
public SomeClass SomeElement;
public List<A> ListA;
}
public class A
{
// ... something appropriate
}

how could I do that?
my problem is in the XmlDocument it's not
<ListA><A>..</A><A>..</A>..</ListA>
but
<ListA><aA><A>..</A></aA><aA><A>..</A></aA>..</ListA>
(notice the enclosing aA tag)
 
L

Lloyd Dupont

I have seen I "could" implement the IXmlSerializable interface.
The problem with that is that I have to manually write to Xml all my
elements, making it very bug prone.

In Java, in such cases, you could call a method kind of
theSerializazer.DefaultSerialization(this);

isn't there a kind of similare possibility with XmlSerializer?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top