blob: 17027e3758cc342e44ee14dbf61896263558967f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# .bashrc-xml
# run different implementation to select data from XML file per XPath expression
# $1 ... XPath expr
# $2 ... file
xml-xpath() {
[ $# -ne 2 ] && int-usage "XPath" "XML" && return
local clrstart=$(test -t && echo -e '\x1b[1;34m' || echo -n)
local clrmiddle=$(test -t && echo -e '\x1b[1;30m' || echo -n)
local clrend=$(test -t && echo -e '\x1b[0m' || echo -n)
# yum install libxml2
echo -e "\n${clrstart}--- xmllint: ${clrmiddle}xmllint --noout --xpath '$1' '$2'${clrstart} ---${clrend}"
xmllint --noout --xpath "$1" "$2"
# yum install xmlstarlet
echo -e "\n${clrstart}--- XMLStarlet: ${clrmiddle}xmlstarlet sel -t -v '$1' '$2'${clrstart} ---${clrend}"
xmlstarlet sel -t -v "$1" "$2"
# yum install xqilla
echo -e "\n${clrstart}--- XQilla: ${clrmiddle}xqilla -P <(echo '$1') -i '$2'${clrstart} ---${clrend}"
xqilla -P <(echo "$1") -i "$2"
}
|