I get an error trying to parse som XML. The error is System.Xml.XmlException: Root element is missing..
, and I can't understand why. Here is the code I run:
MemoryStream xmlStream = new MemoryStream();
StreamWriter xmlStreamWriter = new StreamWriter(xmlStream);
String xml = "<html>\n<body>\n\n<h1>My First Heading</h1>\n\n<p>My first paragraph.</p>\n\n</body>\n</html>";
xmlStreamWriter.Write(xml);
xmlStreamWriter.Flush();
XmlReader reader = XmlReader.Create(xmlStream);
StringWriter jsonStringWriter = new StringWriter();
JsonWriter writer = new JsonTextWriter(jsonStringWriter);
writer.Formatting = Newtonsoft.Json.Formatting.Indented;
JsonMLParser.Encode(reader, writer);
The exception gets thrown during JsonMLParser.Encode()
during reader.MoveToContent()
which is the first call to the xml-reader.