Skip to content

Instantly share code, notes, and snippets.

@ruempel
Created February 23, 2018 08:30
Show Gist options
  • Save ruempel/b0fd3f4210236f7191538306d47d1016 to your computer and use it in GitHub Desktop.
Save ruempel/b0fd3f4210236f7191538306d47d1016 to your computer and use it in GitHub Desktop.
Count nodes of all XML files in a directory recursively with Powershell
$totalnodescount = 0
Get-ChildItem -Recurse -Filter "*.xml" | % {
[System.Xml.XmlDocument] $document = New-Object System.Xml.XmlDocument
$document.load($_.FullName)
$nodes = $document.selectnodes("//*")
Write-Host $nodes.count nodes in $_.Name
$totalnodescount += $nodes.count
}
Write-Host Total nodes count: $totalnodescount
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment