开发者

using C# WriteDocType() to generate Apple Property List-compliant XML

开发者 https://www.devze.com 2022-12-31 07:15 出处:网络
I\'m trying to produce an XmlDocument which has a DocType as specified in Apple\'s Property List (P-L开发者_如何学运维ist) format, which should look like this:

I'm trying to produce an XmlDocument which has a DocType as specified in Apple's Property List (P-L开发者_如何学运维ist) format, which should look like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">

The code I have at the moment looks like this:

using (XmlTextWriter filenameXMLWriter = new XmlTextWriter(ms, null))
{
        filenameXMLWriter.Formatting = Formatting.Indented;
        filenameXMLWriter.WriteStartDocument();
        filenameXMLWriter.WriteDocType("plist", "-//Apple//DTD PLIST 1.0//EN", "http://www.apple.com/DTDs/PropertyList-1.0.dtd", null);

        filenameXMLWriter.WriteStartElement("plist");
        filenameXMLWriter.WriteAttributeString("version", "1.0");
        ..
        ..
}

The DocType never gets written to the document (or at least it never appears in the output). I just get this:

<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">

I'd be grateful for any help.


I tried your code and changed the output Memory Stream to a file path and checked the output file after running the code and the DocType was written to it correctly.

Can you try outputting to a file in your code to see if it's a problem with the WriteDocType line or the Memory Stream?

Regards,

Louis R

0

精彩评论

暂无评论...
验证码 换一张
取 消