Skip to content

Instantly share code, notes, and snippets.

View bielawb's full-sized avatar

Bartek Bielawski bielawb

View GitHub Profile
$caseInsensitive = @'
//node[
translate(@Name, "FIRST", "first") = 'first'
]
'@
Select-Xml -XPath $caseInsensitive -Path .\Test.xml |
ForEach-Object { $_.Node.Name }
$almostRegex = @'
Select-Xml -Path .\Test.xml -XPath "//subNode[@Number > 1]" |
ForEach-Object { $_.Node }
Select-Xml -Path .\TestPage.xhtml -XPath "//*[contains(@id,'test')]" |
ForEach-Object { $_.Node }
$xpath = @'
//*[
contains(
name(),
$addressUp = @'
//host/address[
@addrtype = 'ipv4' and
../status/@state = 'up'
]
'@
$nodeList = Select-Xml -Path .\testLocal.xml -XPath $addressUp |
ForEach-Object { $_.Node }
Select-Xml -Path .\TestPage.xhtml -XPath "//h1[@id = 'title']"
Select-Xml -Path .\TestPage.xhtml -XPath "//x:h1[@id = 'title']" -Namespace @{
x = 'http://www.w3.org/1999/xhtml'
} | ForEach-Object { $_.Node } | Format-Table -AutoSize
$xml = [XML](Get-Content .\Test.xml)
$xml.root.node[0].subNode
Select-Xml -Path .\TestPage.xhtml -XPath //h1 |
ForEach-Object { $_.Node } | Format-Table -AutoSize InnerText, ParentNode