xmlstarlet基于属性选择值

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

带有以下file.xml:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<config>
 <index type="I8">
  <book>2</book>
 </index>
</config>

[我不能用]选择书>

xmlstarlet sel --template --match /config/index[@type="I8"] -c . file.xml

[我不能

用]选择书>
xmlstarlet sel --template --match /config/index[@type='I8'] -c . file.xml

我可以

选择带有的书>
xmlstarlet sel --template --match "/config/index[@type='I8']" -c . file.xml

我可以选择带有的书>

xmlstarlet sel --template --match '/config/index[@type="I8"]' -c . file.xml

如果类型在xml中为type =“ 8”,我可以

用以下方式选择它:
xmlstarlet sel --template --match /config/index[@type="8"] -c . file.xml

为什么?

xmlstarlet 1.6.1
compiled against libxml2 2.9.4, linked with 20904
compiled against libxslt 1.1.29, linked with 10129

具有以下file.xml:[[[2

我可以...
xml xpath xmlstarlet
1个回答
0
投票

此作品有效(在Windows和Ubuntu上测试):

xmlstarlet sel -t -i /config/index/@type=\"I8\" -m //book -c . -b file.xml

与引用有关,您可以在查看下一条语句的输出时看到原因:

xmlstarlet sel -C --template --match /config/index[@type="I8"] -c . file.xml
© www.soinside.com 2019 - 2024. All rights reserved.