如何使用变量作为xmlstarlet val的输入?

问题描述 投票:0回答:1

如何使用变量作为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"
shell xmlstarlet
1个回答
0
投票

删除无效的-v参数,并且您的命令正确解析:

$ xmlstarlet val - <<<"$XML"
- - valid
© www.soinside.com 2019 - 2024. All rights reserved.