Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xmlstarlet sel output new line between values

Tags:

xmlstarlet

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?

like image 387
Dany Avatar asked Jun 14 '13 08:06

Dany


1 Answers

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"
like image 139
Dany Avatar answered Oct 21 '22 12:10

Dany