how to use xmllint in order to get value from xml
15,210
With your testfile:
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Component configuration file -->
<Component>
<Name>install_env</Name>
<HelpString>install_env Com</HelpString>
<Version>1.10.3</Version>
</Component>
I use --xpath argument to get the value of the name tag:
user$ test=$(xmllint --xpath "//Component/Name/text()" testfile)
user$ echo $test
install_env
--xpath implies --noout, which prevents xmllint from outputting anything. Redirect the output to a variable or a file.
Related videos on Youtube
Author by
yael
Updated on September 18, 2022Comments
-
yael almost 2 years
I have the following XML file
<?xml version="1.0" encoding="UTF-8" ?> <!-- Component configuration file --> <Component> <Name>install_env</Name> <HelpString>install_env Com</HelpString> <Version>1.10.3</Version> <Properties>
how to get the value of Name tag - install_env
by using the tool - xmllint