如何使用Powershell读取xml值
如何读取powershell如何使用Powershell读取xml值,powershell,Powershell,如何读取powershell层路径中的值? 我希望得到\\10.10.44.61\案例研究\$xml>的值 <?xml version="1.0" encoding="utf-8"?> <Foo> <Tier Path="\\10.10.44.61\Case Study\" /> <Force Path="\\10.10.44.61\Orto Study" Atomic="False" /> </Foo> ' ([xml]$x
层路径中的值?
我希望得到\\10.10.44.61\案例研究\
$xml>的值
<?xml version="1.0" encoding="utf-8"?>
<Foo>
<Tier Path="\\10.10.44.61\Case Study\" />
<Force Path="\\10.10.44.61\Orto Study" Atomic="False" />
</Foo>
'
([xml]$xml).Foo.Tier.Path
只要您使用的是xml
类型(我通过强制转换来实现),您就可以直接引用路径作为对象的成员。假设您的xml位于名为$xml的变量中:$xml.Foo.Tier.path
?
$xml = '<?xml version="1.0" encoding="utf-8"?>
<Foo>
<Tier Path="\\10.10.44.61\Case Study\" />
<Force Path="\\10.10.44.61\Orto Study" Atomic="False" />
</Foo>'
([xml]$xml).Foo.Tier.Path