【发布时间】:2022-01-06 18:22:51
【问题描述】:
<?xml version="1.0"?>
<Student xmlns="http://www.tibco.com/schemas/TrainingPOCs/SharedRec/Schemas/Schema.xsd">
<Phno type="kwh" value="70" name=""/>
<Phno type="wh" value="100" name="80">
<Type>D</Type>
<Mobile>7777777777</Mobile>
<TPhone>6666666666</TPhone>
</Phno>
<Phno type="kwh" value="200" name="">
<Type>E</Type>
<Mobile>5555555555</Mobile>
<TPhone>4444444444</TPhone>
</Phno
</Student>
我的输入文件 需要用值属性值更新名称属性,只要类型属性有我工作的 kWh 脚本
xmlstarlet edit -N w="http://www.tibco.com/schemas/TrainingPOCs/SharedRec/Schemas/Schema.xsd" -u "/w:Student/w:Phno[@type='kwh']/@name" -x "/w:Student/w:Phno[@type='kwh']/@value" sample.xml
【问题讨论】:
标签: xml shell xmlstarlet