Blow XmlTextWriter
Note: this entry has moved.
Mmm... the following code causes aSystem.NullReferenceException
:
using (FileStream fs = new FileStream(@"e:\xmltextwriter.xml", FileMode.Create))
{
XmlTextWriter tw = new XmlTextWriter(fs, System.Text.Encoding.UTF8);
tw.WriteDocType("html",
"-//W3C//DTD XHTML 1.0 Transitional//EN",
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd",
null);
tw.WriteStartDocument();
tw.Flush();
}
WriteStartDocument()
call. Of course the document being written is not valid according to the Prolog and DTD Declaration specification in XML, but we should get a meaningful exception, right?