【发布时间】:2021-06-06 20:25:51
【问题描述】:
我正在使用bash 和xmllint 来检查以下xml 中的节点:
<?xml version="1.0" encoding="utf-8"?>
<output>
<document>
<sentence id="13">
<text>This is a test sentence.</text>
<entities>
<annotation id="3">
<grammar-form id="0" normal-form="THIS"/>
</annotation>
<annotation id="4">
<grammar-form id="0" normal-form="IS"/>
</annotation>
<annotation id="5">
<grammar-form id="0" normal-form="A"/>
</annotation>
<annotation id="6">
<grammar-form id="0" normal-form="TEST"/>
</annotation>
<annotation id="7">
<grammar-form id="0" normal-form="SENTENCE"/>
</annotation>
<annotation id="12">
<grammar-form id="0" normal-form="."/>
</annotation>
</entities>
</sentence>
</document>
</output>
如何简单地检查每个grammar-form 节点是否存在normal-form 属性?属性值是什么并不重要,我只需要检查它是否存在。
【问题讨论】:
-
我们鼓励提问者展示他们迄今为止为自己解决问题所做的尝试。