I'm trying to use xmllint to parse names of Solr cores from the configuration file.This works:xmllint --xpath /solr/cores/core/@name solr.xml |grep -Po '(?<=name=)[a-z-]+(?=)'And it returns something like:core-acore-b...Which is exactly what I want, but I would like to eliminate grep. It seems like one should be able to do this with just xpath. Without grep, the output looks like:name=core-a name=core-b ...Wrapping the expressions in string() reduces the multiple output to just the first (ie core-a and that's it), which is not useful. How can I apply the string function on each result?
How do I get a list of the values of matching attributes using xmllint and xpath?
shell;xml;xmllint
AFAIK, xmllint is rather limited. But you can use xmlstarlet with its sel command for what you want to do. See xmlstarlet sel --help for usage and an example. With your example, it would be:xmlstarlet sel -T -t -m /solr/cores/core/@name -v . -n solr.xml