我正在使用流动代码来处理一些 xml。但它改变了价值!我该如何纠正?
$xml =[xml]@'
<?xml version="1.0" encoding="UTF-8"?><zabbix_export><hosts><host name="Template_Snmptrap"><dns></dns></host></hosts><dependencies /></zabbix_export>
'@
$random=Get-Random
$filename="{0}\{1}.xml" -f $env:temp,$random
$xml.save($filename)
get-content $filename
结果
PS C:\Users\33333> get-content $filename
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
<hosts>
<host name="Template_Snmptrap">
<dns>
</dns>
</host>
</hosts>
<dependencies />
</zabbix_export>
PS C:\Users\33333>