使用具有字符"&"的标签解析XML文件在价值中

时间:2014-09-03 14:06:37

标签: xml xml-parsing powershell-v2.0

我使用powershell脚本解析XML时,脚本无法解析文件 用“&”

[xml]$XMLfile = Get-Content -Path $filePath 
Cannot convert value "System.Object[]" to type "System.Xml.XmlDocument". Error: "An error occurred while parsing

文件看起来像

<?xml version="1.0" encoding="utf-8"?> 
<property>this is the value of the script & there is another value </property>

1 个答案:

答案 0 :(得分:0)

&字符表示字符引用的开头。使用空格后,XML无效。修复XML。要将&字符表示为数据,请使用&amp;