Is it possible to write REGEX (replace search), which when launched on an XML string [... all]
No.
Use an XML parser to read the string, and then an XML serializer to write it in "pretty mode."
Each XML processor has its own parameters, so it depends on the platform, but here is a somewhat lengthy method that works on DOM Level 3 LS-compliant implementations:
input= implementation.createLSInput();
input.stringData= unprettyxml;
parser= implementation.createLSParser(implementation.MODE_SYNCHRONOUS, null);
document= parser.parse(input);
serializer= implementation.createLSSerializer();
serializer.domConfig.setParameter("format-pretty-print", true);
prettyxml= serializer.writeToString(document);
source
share