如何在Select-XML中指定MaxCharactersFromEntities

时间:2018-03-26 08:43:35

标签: .net xml powershell

与问题XmlException: The input document has exceeded a limit set by MaxCharactersFromEntities类似,我在使用Select-XML处理Powershell中的XML文件时出错。

例外是System.Xml.XmlException: The input document has exceeded a limit set by MaxCharactersFromEntities.

因此,C#问题的解决方案是设置选项MaxCharactersFromEntities,但Powershell中没有类似的参数。

由于 斯特芬

1 个答案:

答案 0 :(得分:0)

一种解决方案是不使用Select-Xml并禁用XmlResolver:

param (
    [string] $Path,
    [string] $XPath
)

$xmlFile = New-Object System.Xml.XmlDocument
$xmlFile.XmlResolver = $null
$xmlFile.Load($Path)

Select-Xml -Xml $xmlFile -XPath $XPath