The way I do it is like so:
public class MyObject
{
public string ID { get; set; }
public string SiteID { get; set; }
public XElement AsXElement
{
get
{
XElement value = new XElement("siteconfigurationinfor",
new XElement("id", ID),
new XElement("id", SiteID));
return value;
}
set
{
ID = value.Element("id").Value;
SiteID = value.Element("siteid").Value;
}
}
public MyObject(XElement value)
{
this.AsXElement = value;
}
}
Of course, you could use the built-in serialization stuff, but I prefer to do it this way (and my actual code uses exception handling in the event of malformed XML or missing values).