I am trying to pull a value out of an xml document using xmllint. but the way xml is structured is following.
<configuration>
<property>
<name>hive.exec.reducers.max</name>
<value>999</value>
<description>max number of reducers will be used. If the one
specified in the configuration parameter mapred.reduce.tasks is
negative, hive will use this one as the max number of reducers when
automatically determine number of reducers.</description>
</property>
<property>
<name>hive.cli.print.header</name>
<value>false</value>
<description>Whether to print the names of the columns in query output.</description>
</property>
<property>
<name>hive.cli.print.current.db</name>
<value>false</value>
<description>Whether to include the current database in the hive prompt.</description>
</property>
</configuration>
Lets say, I want to pull the value of hive.cli.print.current.db, the output should be "false". How xmllint can be used to pull the value from a given name tag in a xml document.
Following xpath query should work.
xmllint --xpath "//property[name[text()='hive.cli.print.current.db']]/value/text()" file.xml
Translation:
Find property element that contains child node (name) with given text and return text contained in another (value) child node.