对于给定的 xml 文件,称为配置文件.xml我想提取value每个conf
元素,并将其存储在变量中以供以后使用。
<configurations>
<conf name="bob"/>
<conf name="alice"/>
<conf name="ted"/>
<conf name="carol"/>
</configurations>
预期输出是:
bob
ailce
ted
carol
I have xpath and xmllint可用的。的 x 路径//conf/@name
获取节点,但输出为name="bob"
,这是我试图避免的。
xmlstarlet sel -t -m '//configurations/conf' -v '@name' -n a.xml
自从工作以来xmllint
看起来没有能力。很好的介绍here.
测试环境:xmlstarlet 版本 1.5.0、Ubuntu 14.04。
然而,它在大文件上失败:ulimit -Sv 500000
(限制为 500Mb)在 1.2Gb XML 上死掉,并且在没有内存限制的情况下堵塞我的计算机。也可以看看:
- 如何验证大型 XML (>100MB) 文件
- 大文件上的 xmlstarlet sel
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)