Notes on common uses for xmlstarlet.
List attributes for all nodes
xmlstarlet sel -t -m '//node' -v @attr1 -o ' ' -v @attr2 -n
Explanation:
-t: template
-m: foreach node /*/node
-v: value of
@attr1: attribute access
-o: output literal string
-n: newline
Data:
<root>
<node attr1="foo" attr2="bar"/>
<node attr1="feed" attr2="back"/>
</root>
Output:
foo bar
feed back