I am trying to serialize an xml document, and one of the nodes is giving me trouble. My xml document is:
<?xml version="1.0" encoding="utf-8"?>
<item id="tcm:38-21324" title="Accessibility Product Accessibility content - 11-INTL" type="Component">
<title>Accessibility Product Accessibility content - 11-INTL</title>
<generalContent xmlns="uuid:bc85180b-db18-412f-b7ad-36a25ff4012f">
<title>Produkttilgængelighed</title>
<style xlink:href="tcm:38-3149-1024" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:title="Horizontal Rule (Blue)">Horizontal Rule (Blue)</style>
<image>
<image xlink:type="simple" xlink:href="tcm:38-33683" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:title="Feature-Image_D_527478227_kp" />
<smallImage xlink:type="simple" xlink:href="tcm:38-33684" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:title="Feature-Image_M_527478227_kp" />
<retinaImage xlink:type="simple" xlink:href="tcm:38-33685" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:title="Feature-Image_T_527478227_kp" />
<altText>Kvinde med briller kigger på en bærbar computer</altText>
<title>Kvinde med briller kigger på en bærbar computer</title>
<imagePosition>Right</imagePosition>
</image>
<description>
<hr class="mainRow__hr mainRow__hr--bbOrange" xmlns="http://www.w3.org/1999/xhtml" />
<p xmlns="http://www.w3.org/1999/xhtml">Vores produkter er designet og udviklet</p>
</description>
</generalContent>
</item>
And this is my model. It works fine with other fields except the description field.
[Serializable()]
[XmlRoot(ElementName = "generalContent", Namespace = "uuid:bc85180b-db18-412f-b7ad-36a25ff4012f")]
public class GeneralContent
{
[XmlElement(ElementName = "title")]
public string Title { get; set; }
[XmlElement(ElementName = "image")]
public Image Image { get; set; }
[XmlElement(ElementName = "description")]
public string Description { get; set; }
}
the code that does the serialization is a generic one and works with all my other models.
public static T MapXmlToType<T>(XElement xmlData) where T:ITridionModel
{
XmlSerializer xmlSerializer = new XmlSerializer(typeof(T));
return (T) xmlSerializer.Deserialize(xmlData.CreateReader());
}
I need to get the "description" node as string. It is basically a rich text field that I need the whole content including the styling values. But, this model as it is right now throws System.InvalidOperationException
for description node. How can I serialize this?