I want to use XML serialization to de-serialize this HTML structures.
When I deserialize this structure, the H3 object has a content of Test Before and a child node containing <span class="red">Small</span>
, but the value of Test After is lost
The following structure is valid in XHTML, though its possibly not valid in XML.
I know someone else asked a similar question here, C# how to deserialize an xml tag embedded in text but they did NOT receive an working answer to their problem.
<div class="row-fluid">
<h3>Test Before <span class="red">Small</span> Test After</h3>
<h4>Header and Footer</h4>
</div>
I know that a workable option would be as follows, but I'm hopping someone has a better technique that uses the XML serializer
<div class="row-fluid">
<h3><![CDATA[[Test Before <span class="red">Small</span> Test After]]></h3>
<h4>Header and Footer</h4>
</div>
Here are some samples of my XML serialization objects
All objects derive from
public abstract class BaseSlideDeckNodeDo
{
protected BaseSlideDeckNodeDo()
{
CssClass = "";
Nodes = new List<BaseSlideDeckNodeDo>();
}
[XmlAttribute("id")]
public string Id { get; set; }
[XmlAttribute("class")]
public string CssClass { get; set; }
[XmlAttribute("style")]
public string Style { get; set; }
[XmlText]
public string Text { get; set; }
[XmlElement("a", typeof(SlideDeckNodeADo))]
[XmlElement("div", typeof(SlideDeckNodeDivDo))]
[XmlElement("p", typeof(SlideDeckNodePDo))]
[XmlElement("h1", typeof(SlideDeckNodeH1Do))]
[XmlElement("h2", typeof(SlideDeckNodeH2Do))]
[XmlElement("h3", typeof(SlideDeckNodeH3Do))]
[XmlElement("h4", typeof(SlideDeckNodeH4Do))]
[XmlElement("h5", typeof(SlideDeckNodeH5Do))]
[XmlElement("h6", typeof(SlideDeckNodeH6Do))]
[XmlElement("img", typeof(SlideDeckNodeImageDo))]
[XmlElement("iframe", typeof(SlideDeckNodeIframeDo))]
[XmlElement("video", typeof(SlideDeckNodeVideoDo))]
[XmlElement("html", typeof(SlideDeckNodeHtmlDo))]
[XmlElement("section", typeof(SlideDeckNodeSectionDo))]
[XmlElement("span", typeof(SlideDeckNodeSpanDo))]
public List<BaseSlideDeckNodeDo> Nodes { get; set; }
}
Example of H3 class
public class SlideDeckNodeH3Do : BaseSlideDeckAnimatedNodeDo
{
}
Example of the Span class
public class SlideDeckNodeSpanDo : BaseSlideDeckAnimatedNodeDo
{
}
Starbucks