xmlstarlet sel output new line between values

Dany picture Dany · Jun 14, 2013 · Viewed 7.5k times · Source

I have the following XML

<process id="test">

</process>
<process id="test2">

</process>

I do get the correct values from the attributes but I want to have them separated on by a new line for further processing.

When using the command

xmlstarlet sel -t -v "count(process/@id" "example.xml)"

I can see the two are separated because it does return 2

The command used to retrieve the attributes is the following

xmlstarlet sel -t -v "process/@id" "example.xml"

Question :

Can the output be returned with a new line for each attribute? If not could it be done with xmllint?

Answer

Dany picture Dany · Jun 14, 2013

I was looking at this for 2 days and i found the following page:

http://www.geekfarm.org/wu/muse/XmlStarlet.html

This clarified a lot to me

I have used the following command to achieve the line breaks

xmlstarlet sel -t -m "process" -n -v "@id" "example.xml"