I have the following xml file
<root>
<deviceID>IO238470374109730497</devicdeID>
<KeyValuePairs>
<KeyValuePair>
<BASE-URL>site.com</BASE-URL>
<Key>329482</Key>
<Value>23094</Value>
</KeyValuePair>
<KeyValuePair>
<BASE-URL>anothersite.com</BASE-URL>
<Key>36657</Key>
<Value>1233</Value>
</KeyValuePair>
<KeyValuePair>
<BASE-URL>yetanothsite.com</BASE-URL>
<Key>3345</Key>
<Value>65087</Value>
</KeyValuePair>
</KeyValuePairs>
</root>
I would like to extract the values of all <BASE-URL>,<Key>,<Value> and set them to variables in a bash script.
executing this command will only print the values
xmlstarlet sel -t -m '//KeyValuePair' -v 'concat(BASE-URL," ", Key, " ", Value, " ")' -nl file.xml
How can I set these values to variables?
I want to extract the values from the xml and send them to variables like this <BASE-URL> to $base_url , <Key> to $key and <Value> to $value.
site.comis not a valid variable name)<BASE-URL>to$base-url,<Key>to$keyand<Value>to$valuebase-urlis also an invalid variable name...