XmlSerialization (other questions)

  • Thread starter Thread starter Lloyd Dupont
  • Start date Start date
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)
 
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?
 
Back
Top