function FindXPath([System.Xml.XmlNode]$node) {
[string]$cur = ''
if($node -ne $null){
if($node.NodeType -eq [System.Xml.XmlNodeType]::Attribute) {
$cur = "/@[$($node.Name)]"
} elseif($node.NodeType -eq [System.Xml.XmlNodeType]::Element) {
$cur = "/$($node.Name)"
} elseif($node.NodeType -eq [System.Xml.XmlNodeType]::Document) {
$cur = ""
} else {
$cur = "Not Supported"
}
$cur = "$(FindXPath($node.ParentNode))$($cur)"
}
return $cur
}
[xml]$xml = Get-Content $xmlfile
$nodes = $xml.SelectNodes("//Guid")
$nodes | % { FindXPath $_ }
Comments