Quantcast
Channel: Parse XML to get node value in bash script? - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 10

Answer by Charles Duffy for Parse XML to get node value in bash script?

$
0
0

The following works when run against your test data:

{ read -r host; read -r username; read -r password; read -r dbname; } \
  < <(xmlstarlet sel -t -m /config/global/resources/default_setup/connection \
      -v ./host -n \
      -v ./username -n \
      -v ./password -n \
      -v ./dbname -n)

This puts the content into variables host, username, password and dbname.


Viewing all articles
Browse latest Browse all 10

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>