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()
精彩评论