2
votes

I am trying to format a xml file using xmlstarlet but I don't want to create a new xml file.

I tried this

xmlstarlet fo --inplace --indent-tab --omit-decl project_00.xml

but the parameter --inplace is not allowed to the fo (format) command.

Does anyone know how I do this?

2

2 Answers

4
votes

The fo subcommand always writes to stdout, so you would have to patch xmlstarlet.

Otherwise

TMP_XML=$(mktemp)
xmlstarlet fo --indent-tab --omit-decl project_00.xml > "$TMP_XML"
mv "$TMP_XML" project_00.xml
1
votes

You could use this one liner

xmlstarlet ed -L -O  project_00.xml

Reference http://xmlstar.sourceforge.net/doc/UG/xmlstarlet-ug.html#idm47077139594320