-
-
Save gpoole/96463780a82fb3ab4314 to your computer and use it in GitHub Desktop.
Take an xpath and a file, run the xpath query and output nicely formatted result XML to the terminal or a file
This file contains hidden or 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
#!/bin/bash | |
if [ -z "$2" ]; then | |
echo "Usage: `basename $0` XPATH FILE" | |
exit 1 | |
fi | |
# For terminal output colourise it too, but for file output just tidy it up | |
if [ -t 1 ]; then | |
xmllint --xpath "$1" $2 | tidy -indent -xml -q | pygmentize -lxml | |
else | |
xmllint --xpath "$1" $2 | tidy -indent -xml -q | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment