Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.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
如何将selectnode与powershell中的where子句一起使用?_Powershell - Fatal编程技术网

如何将selectnode与powershell中的where子句一起使用?

如何将selectnode与powershell中的where子句一起使用?,powershell,Powershell,我有以下xml: <root> <Player uID="2363"> <Name>Roy Mark</Name> <Position>Goalee</Position> <Stat Type="first_name">Roy</Stat> <Stat Type="last_name">Mark</Stat> <Stat Type="jersey_num">2<

我有以下xml:

<root>
<Player uID="2363">
<Name>Roy Mark</Name>
<Position>Goalee</Position>
<Stat Type="first_name">Roy</Stat>
<Stat Type="last_name">Mark</Stat>
<Stat Type="jersey_num">2</Stat>
</Player>
<Player uID="2343">
<Name>Steve Jack</Name>
<Position>Goalee</Position>
<Stat Type="first_name">Steve</Stat>
<Stat Type="last_name">Jack</Stat>
<Stat Type="jersey_num">7</Stat>
</Player>
<root>

我得到了两个球衣号码。请帮助。

关于您的代码,我认为您需要更新此部分:

其中{$fileContents.root.Player.uID-eq“2343”}

致:

其中{$\ root.Player.uID-eq“2343”}


$是从命令导入的数据的占位符。

使用您的代码,我认为您需要更新此部分:

其中{$fileContents.root.Player.uID-eq“2343”}

致:

其中{$\ root.Player.uID-eq“2343”}

$是从命令导入的数据的占位符。

请尝试以下操作:

$player=2343
$fileContents.SelectNodes(“//*[包含(concat(“”,@uID),$player)]///Stat”)|其中{$\类型-eq“jersey\u num”}
试试这个:

$player=2343
$fileContents.SelectNodes(“//*[包含(concat(“”,@uID),$player)]///Stat”)|其中{$\类型-eq“jersey\u num”}
$fileContents = [xml](gc Test.xml)
$temp1 = $fileContents.SelectNodes("/root/Player/Stat[@Type='jersey_num']").innerXML | where {$fileContents.root.Player.uID -eq "2343"}
$fileContents.SelectNodes('/root/Player[@uID="2343"]/Stat[@Type="jersey_num"]/text()')