【发布时间】:2011-08-22 16:31:05
【问题描述】:
$ vim test.xml
<?xml version="1.0" encoding="UTF-8" ?>
<config>
</config>
$ xmlstarlet ed -i "/config" -t elem -n "sub" -v "" test.xml
<?xml version="1.0" encoding="UTF-8"?>
<sub></sub>
<config>
</config>
但我希望 sub 成为 config 的子级。我应该如何更改xpath parameter of -i?
奖励: 是否可以使用属性直接插入孩子,甚至可以将其设置为一个值? 类似的东西:
$ xmlstarlet ed -i "/config" -t elem -n "sub" -v "" -a attr -n "class" -v "com.foo" test.xml
【问题讨论】:
标签: xml command-line xpath command xmlstarlet