How can I get the value from an attribute using xmllint and XPath?

后端 未结 4 1437
小鲜肉
小鲜肉 2020-12-08 13:23

I want to get the value of name and put it in a variable using XMLLint





echo \'cat //body         


        
4条回答
  •  情话喂你
    2020-12-08 14:23

    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)
    

提交回复
热议问题