My implementation of a wrapper command, named xmllint :
-------8<------------------
#!/bin/bash
# 2018-03-23 12:49:27.0 +0100 / Gilles Quenot
<gilles.que...@sputnick.fr>
# wrapper script to have newline delimited output on Xpath querys
args=( "$@" )
if [[ $@ == *--xpath* ]]; then
# iterate over positional parameters
for ((i=0; i<${#args}; i++)); do
if [[ ${args[i]} == --xpath ]]; then
xpath="${args[i+1]}"
delete=("${args[i+1]}" "${args[i]}")
elif [[ -e ${args[i]} || ${args[i]} == file://* || ${args[i]} ==
http*://* || ${args[i]} == - ]]; then
file="${args[i]}"
delete=("${args[i]}")
break
fi
done
if [[ $file == - ]]; then
/usr/bin/xmllint "$@"
else
/usr/bin/xmllint "$args" --shell "${file}" <<< "cat $xpath" |
sed '1d;$d;s/^ ------- *$//;/^$/d; s/^ *//'
fi
else
/usr/bin/xmllint "$@"
fi
-------8<------------------
regards, Gilles Quenot
_______________________________________________
xml mailing list, project page http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml