What am i doing wrong? XML and bash
这是我正在尝试工作的代码:
1 2 3 | echo"type in code" read code1 echo (xmllint --xpath '/rates/currency[code="$code1"]/rate/text()' rates.xml) |
它显示" XPath集为空"
应该从我的xml文档中打印出汇率。哪种汇率取决于货币代码(澳元,美元,欧元等)。如果要这样输入:
1 | echo (xmllint --xpath '/rates/currency[code="GBP"]/rate/text()' rates.xml) |
它将回显代码为GBP的货币的正确汇率。
那是为什么?如何解决?
交换报价定界符
在查询字符串周围使用双引号,以使
1 | echo $(xmllint --xpath"/rates/currency[code="$code1"]/rate/text()" rates.xml) |