我有一个像这样的XML文件设置(请注意第二和第三行中带&的转义字符):
<PDON>
<PDON-USTampa-15StoneHengeRoadFL PDON="Tampa" />
<PDON-USSeattle-17Angel&MarkAve PDON="Seattle" />
<PDON-ESMadrid-XavierMoliní PDON="Madrid" />
</PDON>
当我尝试使用以下内容读取文件时
$mapxml = [xml](get-content $pdonmapfile)
$locationName = "PDON-" #+ whatever the location name is read from XML as it iterates through the XML
$xpath = "/PDON/$locationName"
$lookupval = $mapxml.selectstringnode($xpath)
在&amp;线上输出错误字符。有帮助吗?我猜测必须以不同的方式读取XML,但不知道确切的PowerShell语法。