我正在使用XmlWriter来呈现 HTML.如何让XmlWriter发出一个看起来像这样的正确标签? html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" 这是我到目前为止所拥有的 var xml = XmlWriter.Create(HtmlFileName,
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
这是我到目前为止所拥有的
var xml = XmlWriter.Create(HtmlFileName, new XmlWriterSettings { Indent = true, OmitXmlDeclaration = true}); xml.WriteDocType("html", "-//W3C//DTD XHTML 1.0 Transitional//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd", null); xml.WriteStartElement("html"); xml.WriteAttributeString("xmlns", "http://www.w3.org/1999/xhtml"); ...
最后一行崩溃了
class Program { static void Main(string[] args) { using (var xml = XmlWriter.Create(Console.Out, new XmlWriterSettings { Indent = true, OmitXmlDeclaration = true })) { xml.WriteDocType("html", "-//W3C//DTD XHTML 1.0 Transitional//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd", null); xml.WriteStartElement("html", "http://www.w3.org/1999/xhtml"); xml.WriteAttributeString("xml", "lang", "", "en"); xml.WriteEndElement(); } } }