xml-edit

Edit XML documents from command line

TLDR

Update element value
$ xml edit -u "[//element]" -v "[new value]" [file.xml]
Insert element
$ xml edit -s "[//parent]" -t elem -n "[child]" -v "[value]" [file.xml]
Delete element
$ xml edit -d "[//element]" [file.xml]
Rename element
$ xml edit -r "[//old]" -v "[new]" [file.xml]

SYNOPSIS

xml edit [options] file

DESCRIPTION

xml edit modifies XML documents from command line. Part of xmlstarlet toolkit. Supports inserting, updating, deleting, and renaming elements and attributes.

PARAMETERS

-u, --update xpath

Update matching nodes.
-d, --delete xpath
Delete matching nodes.
-s, --subnode xpath
Add subnode.
-i, --insert xpath
Insert before.
-a, --append xpath
Insert after.
-r, --rename xpath
Rename nodes.
-v, --value value
Value for operation.
-t, --type type
Node type (elem, attr, text).
-n, --name name
Node name.
-L, --inplace
Edit file in place.

INSTALL

sudo dnf install xmlstarlet
sudo pacman -S xmlstarlet
sudo apk add xmlstarlet
sudo zypper install xmlstarlet
brew install xmlstarlet
nix profile install nixpkgs#xmlstarlet

SEE ALSO

xml-select(1), xml-format(1)