Pulling out a value
<configuration> <password>foo & bar</password> </configuration> EOF $ password="$(xml_grep --text_only '/configuration/password' ./test.xml)" $ printf '%s\n' "$password" foo & bar ```
Pulling out a value#
Probably the most common use case for transforming XML in Bash is pulling out a simple value such as a configuration item. When doing so you need to be careful that any XML escaping is undone – you’ll want any
&NAME; characters replaced by their literals in your script.
xml_grep is one tool which can do this: