Get-XmlPeek.ps1
function Get-XmlPeek { <# .SYNOPSIS 使用xpath查询xml元素值 .DESCRIPTION Get-XmlPeek -filePath "./abc.csproj" -xpath "/Project/PropertyGroup/Version" #> param ( [Parameter(Mandatory)][string]$filePath, [Parameter(Mandatory)][string]$xpath ) $versionXml = [xml](get-content $filePath) $appVersionNode = $versionXml.SelectSingleNode($xpath) return $appVersionNode.InnerXml } |