2021-08-16 13:23:55 +01:00
|
|
|
# xml edit
|
2021-08-14 23:17:52 +01:00
|
|
|
|
2021-08-15 19:38:24 +01:00
|
|
|
> Edit an XML document.
|
2021-08-15 12:19:09 +01:00
|
|
|
> More information: <http://xmlstar.sourceforge.net/docs.php>.
|
2021-08-14 23:17:52 +01:00
|
|
|
|
2021-08-21 04:20:02 +01:00
|
|
|
- Delete elements matching an XPATH from an XML document:
|
2021-08-15 19:38:24 +01:00
|
|
|
|
2021-08-24 02:20:17 +01:00
|
|
|
`xml edit --delete "{{XPATH1}}" {{path/to/input.xml|URI}}`
|
2021-08-15 19:38:24 +01:00
|
|
|
|
2021-08-21 04:20:02 +01:00
|
|
|
- Move an element node of an XML document from XPATH1 to XPATH2:
|
2021-08-15 19:38:24 +01:00
|
|
|
|
2021-08-24 02:20:17 +01:00
|
|
|
`xml edit --move "{{XPATH1}}" "{{XPATH2}}" {{path/to/input.xml|URI}}`
|
2021-08-15 19:38:24 +01:00
|
|
|
|
2021-08-21 04:20:02 +01:00
|
|
|
- Rename all attributes named "id" to "ID":
|
2021-08-15 19:38:24 +01:00
|
|
|
|
2021-08-24 02:20:17 +01:00
|
|
|
`xml edit --rename "{{//*/@id}}" -v "{{ID}}" {{path/to/input.xml|URI}}`
|
2021-08-15 19:38:24 +01:00
|
|
|
|
2021-08-24 19:57:47 +01:00
|
|
|
- Rename sub-elements of the element "table" that are named "rec" to "record":
|
2021-08-15 19:38:24 +01:00
|
|
|
|
2021-08-24 02:20:17 +01:00
|
|
|
`xml edit --rename "{{/xml/table/rec}}" -v "{{record}}" {{path/to/input.xml|URI}}`
|
2021-08-15 19:38:24 +01:00
|
|
|
|
2021-08-24 02:20:17 +01:00
|
|
|
- Update the XML table record with "id=3" to the value "id=5":
|
2021-08-15 19:38:24 +01:00
|
|
|
|
2021-08-24 02:20:17 +01:00
|
|
|
`xml edit --update "{{xml/table/rec[@id=3]/@id}}" -v {{5}} {{path/to/input.xml|URI}}`
|
2021-08-15 19:38:24 +01:00
|
|
|
|
2021-08-16 13:23:55 +01:00
|
|
|
- Display help for the `edit` subcommand:
|
2021-08-14 23:17:52 +01:00
|
|
|
|
|
|
|
`xml edit --help`
|