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
1 Answer
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.