我想转换 XML:
<TEST>
<ipAddress value="10.2.1.90"/>
<gitDir value="C:\git\project"/>
<gitArchiveDir value="C:\git\archive"/>
<apacheDocroot value="/var/www"/>
<apacheUsername value="root"/>
</TEST>
进入哈希表:
Name Value
ipAddress 10.2.1.90
gitDir C:\git\project
gitArchiveDir C:\git\archive
apacheDocroot /var/www
apacheUsername root
目前使用这种读取方法:
$invocation = (Get-Variable MyInvocation).Value
$directorypath = Split-Path $invocation.MyCommand.Path
$File = $directorypath + '\config.xml'
$CONFIG = "CONFIG"
$CFG = [xml] ( gc $File )
$CFG.test.ipAddress