I am having a problem trying to deserialise this XML:
<?xml version="1.0" encoding="UTF-8"?>
<links>
<link title="ABC">http://abc.co.uk</link>
<link title="eBay">http://ebay.co.uk</link>
<link title="Best Damn Site on the Web">http://stackoverflow.com</link>
</links>
Using the code:
[XmlRoot("links")]
public class LinksInterface
{
[XmlElement("link")]
public List<LinkElement> Links;
public class LinkElement
{
[XmlAttribute("title")]
public string Title;
[XmlText] // This bit is the troublesome bit!
public LinkElement Link;
}
}
Basically, I need to put the text contents of the element into Links.Link
but the attribute I am trying [XmlText]
does not provide the behaviour I'd expect and I get the error:
There was an error reflecting field 'Links'..
If anyone could point out the error of my ways, I would be most grateful!
Thanks.