-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable ed with complex node value, example(set hadoop file):
xmlstarlet ed -s /configuration -t elem -n "" -v "<property><name>hadoop.tmp.dir</name><value>/usr/hadoop/tmp</value></property><property><name>fs.defaultFS</name><value>hdfs://localhost:9000</value></property>" hadoop/core-site.xml
- Loading branch information
Showing
3 changed files
with
117 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
#!/bin/sh | ||
./xmlstarlet ed \ | ||
#./xmlstarlet ed \ | ||
-s /xml/table/rec -t elem -n new-field -v new-value \ | ||
--var new-field '$prev' \ | ||
-i '$new-field' -t attr -n new-attr -v new-attr-value \ | ||
-s '$new-field' -t elem -n new-subelem -v '' \ | ||
xml/table.xml | ./xmlstarlet c14n | ||
|
||
./xmlstarlet ed -s /xml/table/rec -t elem -n "" \ | ||
-v '<new-field new-attr="new-attr-value">new-value<new-subelem/></new-field>' \ | ||
xml/table.xml | ./xmlstarlet c14n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/sh | ||
./xmlstarlet ed -i '/xml/table/rec[@id=1]' -t attr -n first -v yes xml/table.xml | ||
# insert empty element | ||
./xmlstarlet ed -i '/foo' -t elem -n first xml/entity.xml | ||
./xmlstarlet ed -i '/foo' -t elem -n first -v "" xml/entity.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters