如何使用xml starlet插入实体 [英] How to insert entities with xml starlet
本文介绍了如何使用xml starlet插入实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试用包含与号的文本替换属性值.
I am trying to replace an attribute value with a text containing an ampersand.
<property value="My Product
Developed by me">
用上面的文本替换给定属性的正确语法是什么?
What would be the correct syntax to replace a given attribute by the text above?
到目前为止我尝试过
xmlStarlet\xml.exe edit --inplace --update "/.../property/@value" --value "My Product
Developed by me" myXml.xml
但我最终得到 &替换为 &在那种情况下不打算这样做.
but I end up by getting & replaced by & which is not intended in that case.
推荐答案
使用xmlstarlet
的unesc
命令:
示例 input.xml
文件/片段:
<root>
<property value="empty"></property>
</root>
<小时>
xmlstarlet ed -u '//property/@value' -v 'My Product
Developed by me' input.xml \
| xmlstarlet unesc
输出:
<?xml version="1.0"?>
<root>
<property value="My Product
Developed by me"/>
</root>
这篇关于如何使用xml starlet插入实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文