开发者

xmlwriter writedoctype formatting

开发者 https://www.devze.com 2023-01-28 14:43 出处:网络
I\'m trying to generate this doctype string: <!DOCTYPE games SYSTEM \"transform.dtd\"> This is what I\'ve been trying:

I'm trying to generate this doctype string:

<!DOCTYPE games SYSTEM "transform.dtd">

This is what I've been trying:

$wr开发者_Python百科iter.WriteDocType("games", $null , "transform.dtd", $null )

I'm not entirely sure how to get that exact line.


There's a known bug in PowerShell: passing null to a string parameter results in a String.Empty instead of null.

You can work around it like this:

# Given an XML writer of some sort ...
$writer = [system.xml.xmlwriter]::create("$pwd\test.xml")

# Set up the parameters you want to pass to the method:
$params = @("games",$null,"transform.dtd",$null)

# And invoke it using .Net reflection:
$writer.GetType().GetMethod("WriteDocType").Invoke($writer,$params)

# Eventually, close the writer:
$writer.Close()
0

精彩评论

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