Reading XML file and extracting value

Dear All,

I am reading one XML file to extract value from the particular tag:-
Sample xml is below:-

 
<KeyValuePairs>
<Key>TestString</Key>
<Value>Test12_Pollings</Value>
</KeyValuePairs>

I want to read the value for the KEY tag and there will be multiple key tags :-

 
awk '/<Key>/ { print }' Test.xml 

Output

 
 <Key>Shared_Value</Key>
 

I want output only as

 
Shared_Value

without the Key tags

awk -F'[<>]' '/<Key>/{print $3}' Test.xml

Try the below command

sed -n 's/<Key>\(.*\)<\/Key>/\1/p' filename

For parsing xml file, i use the command xpath

xpath file.xml  //KeyValuePairs/Key/text\(\)

Try:

$ echo "<Key>Shared_Value</Key>" | grep -Po '(?<=<Key>).*(?=</Key>)'
Shared_Value

OR

$ echo "<Key>Shared_Value</Key>" | awk 'gsub(/<Key>|<\/Key>/,x)'
Shared_Value