I am using C# and XmlSerializer to serialize the following class:
public class Title
{
[XmlAttribute("id")]
public int Id { get; set; }
public string Value { get; set; }
}
I would like this to serialize to the following XML format:
<Title id="123">Some Title Value</Title>
In other words, I would like the Value property to be the value of the Title element in the XML file. I can’t seem to find any way to do this without implementing my own XML serializer, which I would like to avoid. Any help would be appreciated.
Try using
[XmlText]:Here’s what I get (but I didn’t spend a lot of time tweaking the XmlWriter, so you get a bunch of noise in the way of namespaces, etc.: