1
votes

Given:

<UOIS UOI_ID="9c168282a881848971a85eaa32e7f213f7791e88" CONTENT_TYPE="VIDEO" NAME="2016_129_17_1_PM_Moss.mov" VERSION="1">

How can I use xmlstarlet to pull the values for UOI_ID and NAME ?

2

2 Answers

1
votes

The following should output UOI_ID and NAME, from every UOIS element, separated by comma :

xmlstarlet sel -t -m "//UOIS" -v "concat(@UOI_ID, ', ' , @NAME)" -n your_xml.xml
0
votes

So you can try this approach.

$ xmlstarlet sel -t -v "/UOIS[UOI_ID= 9c168282a881848971a85eaa32e7f213f7791e88]/UOI_ID/" yourfilename.xml

Apply the same idea for the name value. If you need any further assistance please, let me know!