XML, Embedding HTML in XML
The comment syntax <!-- this is a comment --> generates an error if the comment contains “--“. Seems a bit stupid to complain about an invalid comment terminator when it isn’t intended to be a comment terminator. What gives? Do comments need to be escaped in some way?
SelectNodes returns a Count == 0 XMLNodeList if the xpath query matches nothing.
Can’t have “]]>” inside a CDATA block.
Encoding HTML for placement within an XML file:
XmlElement htmlNode = xqargResult.OwnerDocument.CreateElement("ds:html", nsmgr.LookupNamespace("ds"));
xqargResult.AppendChild(htmlNode);
htmlNode.InnerText = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(html));
Decoding the XML file to recover embedded HTML:
string html = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(result.SelectSingleNode(@"ds:html", nsmgr).InnerText));