How can I get the value from an attribute using xmllint and XPath?
shell, xml, xpath
Solution
You need to use fn:string(), which will return the value of its argument as `xs:string`. In case its argument is an attribute, it will therefore return the attribute's value as `xs:string`.
test=$(xmllint --xpath "string(//body/value/@name)" test.xml)
Problem
I want to get the value of name and put it in a variable using XMLLint ``` <body> <value name="abc"></value> </body> echo 'cat //body/value/@name' | xmllint --shell "test.xml" / > ------- name="abc" / > ``` So I want to assign the value "abc" to variable $test