如何在PowerShell中配置System.Xml.XmlWriter

我试图处理XmlWriter对象:
try
{
    [System.Xml.XmlWriter] $writer = [System.Xml.XmlWriter]::Create('c:\some.xml')
}
finally
{
    $writer.dispose()
}

错误

Method invocation Failed because
[System.Xml.XmlWellFormedWriter]
doesn’t contain a method named
dispose’.

另一方面:

$writer -is [Idisposable]
 # True

我该怎么办?

dispose是System.Xml.XmlWriter上的 protected.你应该使用关闭.
$writer.Close

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念