I'm trying to deserialize xml below:
<venue href="http://SomeUrl">
<location id="ABC"/>
<title>Some title</title>
</venue>
When I wrap it with class like below XmlSerializer
works like charm
[XmlRoot(ElementName = "venue")]
public class VenueModel
{
[XmlElement("location")]
public Location Location;
[XmlElement("title")]
public string Title;
[XmlAttribute("href")]
public string Href;
}
public class Location
{
[XmlAttribute("id")]
public string Id;
}
But in my opinion wrapping simple string from Location
into separate class it's quite dull solution. What I would like to achieve is to create simpler flatten model like below:
[XmlRoot(ElementName = "venue")]
public class VenueModel2
{
[SomeMagicAttribute]
public string LocationId;
[XmlElement("title")]
public string Title;
[XmlAttribute("href")]
public string Href;
}
so first question? is it possible using C# System.Xml.Serialization
? If it is, what is the magic attribute to get this data?