替换XML文件中的动态内容
发布时间:2020-12-16 07:55:36 所属栏目:百科 来源:网络整理
导读:快速摘要:我需要创建一个 Bash脚本,每周自动更改一个节点内的文本.脚本将匹配节点并替换其中的文本(如果可能的话)?我该怎么做? 长摘要: 我主持一个Minecraft服务器,它有一个商店,每个都有自己的.xml文件放在/ ShowcaseStandalone / ffs-storage /目录中.
快速摘要:我需要创建一个
Bash脚本,每周自动更改一个节点内的文本.脚本将匹配节点并替换其中的文本(如果可能的话)?我该怎么做?
长摘要: XML文件: <?xml version="1.0" encoding="UTF-8"?> <scs-shop usid="cac8480951254352116d5255e795006252d404d9" version="2" type="storage"> <enchantments type="string"/> <owner type="string">Chadward27</owner> <world type="string">Frisnuk</world> <itemStack type="string">329:0</itemStack> <activity type="string">BUY</activity> <price type="double">55.0</price> <locX type="double">487.5</locX> <locY type="double">179.0</locY> <locZ type="double">-1084.5</locZ> <amount type="integer">0</amount> <maxAmount type="integer">0</maxAmount> <isUnlimited type="boolean">true</isUnlimited> <nbt-storage usid="23dffac5fb2ea7cfdcf0740159e881026fde4fa4" version="2" type="storage"/> </scs-shop> 操作系统:Linux Ubuntu 12.04
您可以使用
xmlstarlet 在shell中编辑XML文件,如下所示:
xmlstarlet edit -L -u "/scs-shop/price[@type='double']" -v '99.66' file.xml 注意 >“/ scs-shop / price [@ type =’double’]”是一个Xpath表达式>请参阅xmlstarlet ed –help (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |