Sometimes I need to quickly extract some arbitrary data from XML files to put into a CSV format. What’s your best practices for doing this in the Unix terminal? I would love some code examples, so for instance how can I get the following problem solved?
Example XML input:
<root> <myel name="Foo" /> <myel name="Bar" /> </root>
My desired CSV output:
Foo, Bar,
If you just want the name attributes of any element, here is a quick but incomplete solution.
(Your example text is in the file example)