简体   繁体   English

C#CreateDocumentType用于非PUBLIC

[英]C# CreateDocumentType for non-PUBLIC

I want to get the following output: 我想获得以下输出:

<?xml version="1.0" encoding="Windows-1252"?>
<!DOCTYPE SUPRMRT SYSTEM "suprmrt.dtd">

I have the following code: 我有以下代码:

XmlDocument doc = new XmlDocument();
XmlDocumentType docType = doc.CreateDocumentType("SUPRMRT", "SYSTEM", "suprmrt.dtd", null);
doc.AppendChild(docType);
doc.Save(Console.out);

This produces: 这会产生:

<?xml version="1.0" encoding="Windows-1252"?>
<!DOCTYPE SUPRMRT PUBLIC "SYSTEM" "suprmrt.dtd">

So my question is can I get a result where PUBLIC is replaced by SYSTEM? 所以我的问题是,我可以得到一个结果,其中PUBLIC被SYSTEM取代? Also, if I replace "SYSTEM" with null, I get a set of empty quotes. 另外,如果我用“null”替换“SYSTEM”,我会得到一组空引号。 Can I stop that from happening? 我可以阻止这种情况发生吗?

Write it like this. 像这样写。

XmlDocumentType docType = doc.CreateDocumentType("SUPRMRT", null, "suprmrt.dtd", null);

Here is the MSDN Documentation 这是MSDN文档

publicId publicId

Type: System.String 键入:System.String

The public identifier of the document type or null. 文档类型的公共标识符或null。 You can specify a public URI and also a system identifier to identify the location of the external DTD subset. 您可以指定公共URI以及系统标识符,以标识外部DTD子集的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM