是否可以将查询结果与编辑结合在一起?

时间:2019-04-19 07:10:09

标签: xml xpath xmlstarlet

假设我得到了这个xml文件:

<xml>
        <Attribute name="attribute1">
                <Value1>True</Value1>
                <Value2>True</Value2>
                <ID>1</ID>
        </Attribute>
        <Attribute name="attribute2">
                <Value1>True</Value1>
                <Value2>True</Value2>
                <ID>2</ID>
        </Attribute>
        <Attribute name="attribute3">
                <Value1>True</Value1>
                <Value2>True</Value2>
                <ID>3</ID>
        </Attribute>
</xml>

我想做的是:

  1. 获取“名称”属性的值(为此,我使用sel -t -m "xml" -m "Attribute" -v "@name"

  2. 使用检索到的值并更新节点的相应ID元素,使结果显示为例如attribute1 <ID>attribute1</ID>

使用XmlStarled可以吗?

0 个答案:

没有答案