As a part of my development I’d like to be able to validate an entire folder’s worth of XML files against a single XSD file. A PowerShell function seems like a good candidate for this as I can then just pipe a list of files to it like so: dir *.xml | Validate-Xml -Schema .\MySchema.xsd
I’ve considered porting C# code from the Validating an Xml against Referenced XSD in C# question, but I don’t know how to Add handlers in PowerShell.
I wrote a PowerShell function to do this:
Usage:
dir *.xml | Test-Xml -Schema “.\MySchemaFile.xsd” -Namespace “http://tempuri.org“
Code: