When I have an XML file like this:
<guests>
<guest>
<name>Adam</name>
<music>Silence</music>
<dish>Vegetables</dish>
<beverage>Water</beverage>
</guest>
<guest>
<name>Brutus</name>
<music>Verdi</music>
<dish>Meat</dish>
<beverage>Mulsum</beverage>
</guest>
</guests>
Is there already an elegant bash-y way of formatting this into a table? I imagine it like this:
cat myPartyGuests.xml | xmlToTable --lines "/guests/guest" --columns "name, beverage, dish"
that gives something like this:
name beverage dish
Adam Water Vegetables
Brutus Mulsum Meat
I already know that if I could get the XML into a form like this:
name;beverage;dish
Adam;Water;Vegetables
Brutus;Mulsum;Meat
...I can use column -s\; -t
to get exactly my desired output, so only the "XML to CSV" step is missing.