Can different datasets with different fieldnames be de-serialized into a class??  
Author Message
Shrini





PostPosted: .NET Remoting and Runtime Serialization, Can different datasets with different fieldnames be de-serialized into a class?? Top

[XmlRoot(ElementName = "P")]
public class P
{
private string _P1;
private string _P2;
[
XmlElement(ElementName = "P1")]
[
XmlElement(ElementName = "L1")]
public string P1
{
get { return _P1; }
set { _P1 = value; }
}
[
XmlElement(ElementName = "P2")]
[
XmlElement(ElementName = "L2")]
public string P2
{
get { return _P2; }
set { _P2 = value; }
}
}

below is the xml:

<P>
<P1>text</P1>
<P2>text</P2>
</P>
<P>
<L1>text</L1>
<L2>text</L2>
</P>

When I try to de-serialize the xml, it gives me "There was an error reflecting type". What will be the best way to do this. I am able to deserialize the if I have a single xmlelement. I want to be able to searilize class and de-serialize xml into class.

Please advice,
shrini



.NET Development32