xmllint --format ugly.xml --output pretty.xml xmllint --valid --noout document.xml Or, explicitly using a DTD file:
xmllint --xpath "//book/title" library.xml To save the result to a file:
xmllint --dtdvalid schema.dtd document.xml xmllint --schema myschema.xsd --noout data.xml 5. Extract Data with XPath The --xpath option is extremely useful for querying XML:
xmllint --xpath "//item/name" inventory.xml > output.txt xmllint --noblanks document.xml --output minified.xml Real-World Examples for Windows Users Example 1: Batch Validate All XML Files in a Folder In PowerShell or cmd:
<settings> <database host="localhost" port="3306"/> </settings> Extract the host attribute:
xmllint --xpath "string(//database/@host)" config.xml Output: localhost Because xmllint works with standard input, you can chain commands:
: Try running xmllint --help to see all available options, and consider integrating it into your CI/CD pipelines on Windows Server.
xmllint --format ugly.xml --output pretty.xml xmllint --valid --noout document.xml Or, explicitly using a DTD file:
xmllint --xpath "//book/title" library.xml To save the result to a file: xmllint windows
xmllint --dtdvalid schema.dtd document.xml xmllint --schema myschema.xsd --noout data.xml 5. Extract Data with XPath The --xpath option is extremely useful for querying XML: xmllint --format ugly
xmllint --xpath "//item/name" inventory.xml > output.txt xmllint --noblanks document.xml --output minified.xml Real-World Examples for Windows Users Example 1: Batch Validate All XML Files in a Folder In PowerShell or cmd: database host="localhost" port="3306"/>
<settings> <database host="localhost" port="3306"/> </settings> Extract the host attribute:
xmllint --xpath "string(//database/@host)" config.xml Output: localhost Because xmllint works with standard input, you can chain commands:
: Try running xmllint --help to see all available options, and consider integrating it into your CI/CD pipelines on Windows Server.