I am using xmllint to parse xml file which has several tags and each tag has several attributes. Sample structure as shown below:
<root> <child attr1="abc" attr2="def" attr3="ghi" /> ... ... </root>
I need to fetch the values from the attributes
So far, I have tried the following which is giving the data of one attribute perfectly
echo 'cat //root/child/@attr1' | xmllint --shell data.xml
So, my question is, how can we specify more than one attributes in the string to get the required output as
attr1="abc" attr2="def" attr3="ghi"
I tried the following for this, but no good result:
echo 'cat //root/child/@*[attr1|attr2|attr3]' | xmllint --shell data.xml echo 'cat //root/child/@*[attr1 or attr2 or attr3]' | xmllint --shell data.xml
output for above was that the echo statement was re-echoed again that means, the xmllint didn't accept it as input.
Any ideas on how to go about this?