我正在尝试生成此doctype字符串:
<!DOCTYPE games SYSTEM "transform.dtd">
这就是我一直在尝试的:
$writer.WriteDocType("games", $null , "transform.dtd", $null )
我不完全确定如何获得确切的行。
答案 0 :(得分:6)
PowerShell中存在一个已知错误:passing null to a string parameter results in a String.Empty instead of null.
你可以这样解决:
# 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()