The quickest way is to download a standalone xmllint.exe from a trusted open-source repository.
[xml]$xml = Get-Content .\file.xml $xml.SelectNodes("//book/title") | ForEach-Object $_.InnerText
| Feature | xmllint | PowerShell (Native) | | :--- | :--- | :--- | | | Concise, Unix-style flags. | Verbose, object-oriented. | | Validation | Excellent (XSD/DTD). | Possible, but requires writing C# style code. | | Formatting | xmllint --format file.xml | $xml = [xml](Get-Content file.xml); $xml.Save(...) | | Learning Curve | High if you don't know Unix. | High if you don't know .NET objects. | xmllint windows
(The - tells xmllint to read from stdin.)
xmllint --format ugly.xml --output pretty.xml The quickest way is to download a standalone xmllint
You can download pre-compiled Windows binaries (usually from open-source mirrors or the libxml2 project page).
However, xmllint remains far superior for validation, formatting, and XPath 1.0 support. | | Validation | Excellent (XSD/DTD)
type ugly.xml | xmllint --format - > formatted.xml