1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-07-04 21:15:23 +02:00
tldr/pages/common/xml-edit.md

29 lines
982 B
Markdown
Raw Normal View History

# xml edit
> Edit an XML document.
2025-05-11 21:14:19 +03:00
> More information: <https://xmlstar.sourceforge.net/doc/UG/xmlstarlet-ug.html#idm47077139594320>.
- Delete elements matching an XPATH from an XML document:
2025-05-11 21:14:19 +03:00
`xml {{[ed|edit]}} {{[-d|--delete]}} "{{XPATH1}}" {{path/to/input.xml|URI}}`
- Move an element node of an XML document from XPATH1 to XPATH2:
2025-05-11 21:14:19 +03:00
`xml {{[ed|edit]}} {{[-m|--move]}} "{{XPATH1}}" "{{XPATH2}}" {{path/to/input.xml|URI}}`
- Rename all attributes named "id" to "ID":
2025-05-11 21:14:19 +03:00
`xml {{[ed|edit]}} {{[-r|--rename]}} "{{//*/@id}}" -v "{{ID}}" {{path/to/input.xml|URI}}`
2021-08-24 14:57:47 -04:00
- Rename sub-elements of the element "table" that are named "rec" to "record":
2025-05-11 21:14:19 +03:00
`xml {{[ed|edit]}} {{[-r|--rename]}} "{{/xml/table/rec}}" -v "{{record}}" {{path/to/input.xml|URI}}`
2021-08-23 21:20:17 -04:00
- Update the XML table record with "id=3" to the value "id=5":
2025-05-11 21:14:19 +03:00
`xml {{[ed|edit]}} {{[-u|--update]}} "{{xml/table/rec[@id=3]/@id}}" {{[-v|--value]}} {{5}} {{path/to/input.xml|URI}}`
- Display help:
2025-05-11 21:14:19 +03:00
`xml {{[ed|edit]}} {{[-h|--help]}}`