如何使用变量作为xmlstarlet validate命令的输入?这是完整的例子:
read -r -d '' XML <<"EOF"
<?xml version="1.0"?>
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications
with XML.</description>
</book>
</catalog>
EOF
# emits a usage message, exits with status 2
xmlstarlet val -v . <<< "$XML"
# also emits a usage message and exits with status 2
xmlstarlet val -v - <<< "$XML"
删除无效的-v
参数,并且您的命令正确解析:
$ xmlstarlet val - <<<"$XML"
- - valid