我将 XML 文件内容分配给一个变量$config
,然后使用另一个变量$market
来存储 XPath 查询的输出:
$config = Get-Content -Path "C:\files\configs\config.xml" -raw
$market = (select-xml -Content $config -xpath /process-config/input/filePattern/marketCode).node.'#text'
然后我添加以下行:
write-host this is $market
输出是这样的:
PS C:\ps_scripts> .\xmltest.ps1
this is citigroup_ams
#text
-----
citigroup_ams
我想要的输出是:
PS C:\ps_scripts> .\xmltest.ps1
this is citigroup_ams
我试图| Out-Null
在第二行的末尾添加,但在这种情况下,只有 Write-Host cmdlet 的输出被抑制。有没有其他方法可以抑制输出Select-Xml
?