Created
February 23, 2018 08:30
-
-
Save ruempel/b0fd3f4210236f7191538306d47d1016 to your computer and use it in GitHub Desktop.
Count nodes of all XML files in a directory recursively with Powershell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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