Get xmllint to output xpath results \n-separated, for attribute selector
The question is old but as I came to this post searching a solution to the same problem, here is my solution
On linux add sed substitution to split output:
$ xmllint example.xml --xpath "/config/*/@*" | sed "s| key|\nkey|g"
of course the substitution expression depends on your xml structure and your xpath query.
And you can even add line numbers on each line if you add nl
$ xmllint example.xml --xpath "/config/*/@*" | sed "s| key|\nkey|g" | nl
Which gives
1 key1="value1 " 2 key2=" value2" 3 key3="value3" 4 key4=" value4 "