所以我不得不说我是使用 PowerShell 解析 XML 的新手。话虽如此,我该如何组合多个 -XPath 以便我可以完成构建我的表达式报告。请让我知道,我已经尝试了几种组合,但它们似乎都不适用于命名空间 XML。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" niaVersion="12.0.0.756" xmlns="http://something.com/something/hotfix/manifest">
<releases>
<release name="mid November 2017">
<hotfixes>
<hotfixref name="DE002" description="" defectSuite="n/a" supportEscalation="n/a" internalNotes="" customer="n/a">
<packages>
<package type="All" />
</packages>
<components>
<component type="" />
<component type="" />
</components>
</hotfixref>
<hotfixref name="DE5728" description="" defectSuite="DS001" supportEscalation="n/a" internalNotes="" customer="n/a">
<packages>
<package type="Full" />
</packages>
<components>
<component type="" />
</components>
</hotfixref>
</hotfixes>
</release>
</releases>
</manifest>
[xml]$xdoc=Get-Content $PSScriptRoot\Manifest.xml
$ns = @{test ="http://something.com/something/hotfix/manifest"}
$ver = Select-Xml -Xml $xdoc -XPath '//test:release' -Namespace $ns
$hfu = Select-Xml -Xml $xdoc -XPath '//test:hotfixref' -Namespace $ns
foreach ($v in $ver){
$v | Select-Object -ExpandProperty node
$hfu | Select-Object -ExpandProperty node