2012-03-27 77 views

回答

3

的开头你需要一个XDocumentType添加到XDocument的开头:

var xDocument = new XDocument(
    new XDocumentType(
    "smil", 
    "-//W3C//DTD SMIL 2.0//EN", 
    "http://www.w3.org/2001/SMIL20/SMIL20.dtd", 
    null 
), 
    new XElement("Root") 
); 
+0

你如何接受在stackoverflow中的答案。我不断收到有关不接受答案的警告。 – user1204195 2012-03-27 02:59:24

+1

@ user1204195:单击数字下方左侧的空白复选标记。 – BoltClock 2012-03-27 03:02:14

+1

@ user1204195:您点击投票计数器下方答案左侧的复选标记。 – 2012-03-27 03:02:48

0

有你试过XmlDocument.CreateDocumentType()MSDN link

0

试试这个 http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.createdocumenttype.aspx

//创建的XmlDocument。 XmlDocument doc = new XmlDocument();

//Create a document type node and 
//add it to the document. 
XmlDocumentType doctype; 
doctype = doc.CreateDocumentType("book", null, null, "<!ELEMENT book ANY>"); 
doc.AppendChild(doctype); 

//Create the root element and 
//add it to the document. 
doc.AppendChild(doc.CreateElement("book")); 
相关问题