Tech /

Xml Star





edit SideBar

Xml Star

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
Recent Changes (All) | Edit SideBar Page last modified on 01 February 2020, at 05:02 PM UTC Edit Page | Page History
Powered by PmWiki