如何使用 xmllint

问题描述

我正在使用 bashxmllint 检查以下 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 属性?属性值是什么并不重要,我只需要检查它是否存在。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)