How can I get xmllint to output multiple results of xpath selector for attributes "per line"?
Take this example:
<?xml version="1.0" encoding="ISO-8859-1"?>
<config>
<tagX key1="value1 " key2=" value2"/>
<tagY key3="value3" key4=" value4 "/>
</config>
$ xmllint example.xml --xpath "/config/*/@*"
The result is:
key1="value1 " key2=" value2" key3="value3" key4=" value4 "
What I'd like to get is:
key1="value1 "
key2=" value2"
key3="value3"
key4=" value4 "
Would I need to split after even-numbered quote marks, or is there any neater way to do this?
There's a related question, about the same subject except it's about picking out contents of <tag>value</tag>
, and not <tag attribute="value" />
echo 'cat /config/*/@*[starts-with(name(),"key")]' | xmllint --shell input.xml
– Lifework| grep =
and it's fine. (actually, no[starts-with()...
just/@*
I used "key1, key2..." as metasyntactic variables, the actual attribute names would be arbitrary.) – Sleuthgrep -v
and done! – Lifework=
, and undesired are rather fixed:/ > cat /config/*/@*
and ` -------` - and it's possible the value might contain-------
, sogrep '='
is sure to find what I want (unless I use=
in the selector, which I don't.) – Sleuth