我正在尝试生成此文档类型字符串:
<!DOCTYPE games SYSTEM "transform.dtd">
这是我一直在尝试的:
$writer.WriteDocType("games", $null , "transform.dtd", $null )
我不完全确定如何得到那条确切的线。
最佳答案
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()
关于.net - xmlwriter writedoctype格式化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4309728/