sed查找xml节点符合的值输出显示
xml文件如下:
<wordbook><item> <word>gravity</word>
<trans><![CDATA[n. 重力,地心引力;严重性;严肃,庄严]]></trans>
<phonetic><![CDATA[[ˈgrævətɪ]]]></phonetic>
<tags>未分组</tags>
<progress>3</progress>
</item><item> <word>gratitude</word>
<trans><![CDATA[n. 感谢;感激之情]]></trans>
<phonetic><![CDATA[['grætɪtjuːd]]]></phonetic>
<tags>未分组</tags>
<progress>3</progress>
</item><item> <word>graphic</word>
<trans><![CDATA[adj. 生动的,形象的;图表的
n. 图表]]></trans>
<phonetic><![CDATA[['græfɪk]]]></phonetic>
<tags>未分组</tags>
<progress>3</progress>
</item><item> <word>gracious</word>
<trans><![CDATA[adj. 亲切的,和蔼的;仁慈的;高尚的]]></trans>
<phonetic><![CDATA[['greɪʃəs]]]></phonetic>
<tags>未分组</tags>
<progress>4</progress>
</item><item> <word>gown</word>
<trans><![CDATA[n. 长袍,长外衣;礼服]]></trans>
<phonetic><![CDATA[[gaʊn]]]></phonetic>
<tags>未分组</tags>
<progress>3</progress>
</item><item> <word>contest</word>
<trans><![CDATA[vt. 竞争;比赛;争论;争辩
n. 竞争;比赛;争论;争辩]]></trans>
<phonetic><![CDATA[['kɒntest]]]></phonetic>
<tags>未分组</tags>
<progress>5</progress>
</item></wordbook>
用sed命令实现查找progress值为3的所有item节点。
输出结果为:
<item> <word>gravity</word>
<trans><![CDATA[n. 重力,地心引力;严重性;严肃,庄严]]></trans>
<phonetic><![CDATA[[?gr?v?t?]]]></phonetic>
<tags>未分组</tags>
<progress>3</progress>
</item><item> <word>graphic</word>
<trans><![CDATA[adj. 生动的,形象的;图表的
n. 图表]]></trans>
<phonetic><![CDATA[['gr?f?k]]]></phonetic>
<tags>未分组</tags>
<progress>3</progress>
</item><item> <word>gown</word>
<trans><![CDATA[n. 长袍,长外衣;礼服]]></trans>
<phonetic><![CDATA[[ga?n]]]></phonetic>
<tags>未分组</tags>
<progress>3</progress>
</item>