StringBuilder output = new StringBuilder();
using (XmlWriter writer = XmlWriter.Create(output))
{
writer.WriteStartElement("test");
writer.WriteCData("taco\vbell");
writer.WriteEndElement();
writer.WriteEndDocument();
}
Console.WriteLine(output.ToString());
WriteCData throws the following ArgumentException, “‘\v’, hexadecimal value 0x0B, is an invalid character”
I thought CData can take any kind of data. Since this is not the case, what characters do I have to escape? Thanks.
No, XML itself cannot represent any characters earlier than U+0020 other than tab, carriage return, and line feed.
From the spec, section 2.2:
There’s no standard way of representing the "forbidden" characters, unfortunately. You’d have to create your own escaping mechanism.