Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Powershell读取xml值_Powershell - Fatal编程技术网

如何使用Powershell读取xml值

如何使用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

如何读取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]$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