Hi,
Ive got a problem with something im working on. I have some Xml
that i am Deserializing in to two classes but im not convinced there
is not a better way. One of the classes is purely serving to mimic the
structure of the Xml rather then serving any useful purpose so i would
like to eliminate it but im having a bit of trouble finding the right
method on the serializer to eliminate it.
The Xml looks a bit like:
<nodea>
<nodeb>
<nodec />
<noded />
</nodeb>
</nodea>
and the current C# looks like:
//Holds nodea
public class nodea
{
[XmlElement("nodeb",typeof(nodeb))]
public nodeb dataholder;
//Method to get nodec from dataholder
[XmlIgnore]
public string nodec
{
get {return this.dataholder.nodec;}
set {this.dataholder.nodec = value;}
}
//Method to get noded from dataholder
[XmlIgnore]
public string noded
{
get {return this.dataholder.noded;}
set {this.dataholder.noded = value;}
}
}
//Holds node data
public class nodeb
{
[XmlElement("nodec",typeof(string))]
public string nodec;
[XmlElement("noded",typeof(string))]
public string noded;
}
What i would really like to be able to do is eliminate the nodeb class
and just have the nodec & noded values written to the apropriate
string members of class nodea but like i said i cant figure out how to
do it. Is there a way to pass Xpath through the XmlElement method to
tell it to get the value from elsewhere in the tree or is there some
other method entirely i can use?
Many many many many thanks in advance for your responses,
Liam Leane