I can't seem to find exactly how to do this. I have this XML file
<session>
<translations>
<translation>
<inside>198.18.133.1</inside>
<name>adfs.domain1.com</name>
</translation>
<translation>
<inside>198.18.135.60</inside>
<name>hds.domain2.com</name>
</translation>
</translations>
</session>
and I want to extract the domain from a particular name node based on the string found in the inside node. As you can see I have multiple name and inside nodes. With the following Bash file I can extract the first instance of name
#!/bin/bash
domain="$(echo "cat /session/translations/translation/name/text()" | xmllint --nocdata --shell session.xml | sed '1d;$d')"
domain="${domain:5}"
printf '%s\n' "Domain is: $domain"
This will give me domain1.com.
Sometimes I could have more translations or less and they aren't always in the same order. So I need a way to pull the name IF the inside node matches 198.18.133.1 or pull the name IF the inside node matches 198.18.135.60, etc.