XML : Search for value in xml file bash script

I have xml file:

  <?xml version="1.0" encoding="UTF-8"?>  <metadata>  <groupId>group</groupId>  <artifactId>project100</artifactId>  <versioning>    <latest>1.2.1-black</latest>    <release>1.2.1-black</release>   <versions>     <version>1.0.0</version>     <version>1.0.0-black</version>     <version>1.0.2</version>     <version>1.0.1</version>     <version>1.2.0</version>     <version>1.2.1-black</version>    </versions>   </versionsing>  </metadata>    

And also I have a variable like: $ID=1.0.2 and I want to check if this id exist in my xml file. I try something like this:

  'cat ///metadata/versioning/version/text()' | xmllint --shell $content | grep -v "^/ >"    

where $contenet is my xml file but this shows mi something like this:

  warning: failed to load external entity "<version>1.0.0</version>    

for each entity from xml file. I have no idea how to do this. I kind of noobie in bash scripting

No comments:

Post a Comment