Search code examples
xmlstarlet

xmlstarlet format


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?


Solution

  • 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