]$ xmllint --version
xmllint: using libxml version 20626
My xml file looks something like this:
<projects>
<architecture name="ARCH1">
<project label="StringA1" type="StringB1" state="StringC1"/>
......
</architecture>
<architecture name="ARCH2">
<project label="StringA2" type="StringB2" state="StringC2"/>
......
</architecture>
</projects>
For example, I would like to obtain the value StringB2
given the condition name==ARCH2
and state==StringC2
. Is it possible using xmllint
command line options, if yes, how ? Some examples will be beneficial.
I can extract these using sed
or awk
but that may not be a good solution.
Use:
or if you just want the string and only the string:
While testing this statement I realized, that the ubuntu (12.04) version of xmllint (20708) terminates with a segfault when executing this command. I cloned the most recent version from https://git.gnome.org/browse/libxml2/refs/ and compiled. Now the command above works.