Returns a formatter that prints XML with indentation.
class XmlService method .getPrettyFormat()
XmlService is the Apps Script service.
.getPrettyFormat() is the method name you will see after a dot in your code.
What it does
Why it's used
- Print readable indented XML for logs or files.
- Easier to debug than one long line.
Common errors
- Forgetting parentheses on getPrettyFormat. Write XmlService.getPrettyFormat(), not XmlService.getPrettyFormat or getPrettyFormat by itself.
- Skipping dots between chained calls. Each step needs a dot, like XmlService.getPrettyFormat().
- Adding spaces where they do not belong. Write XmlService.getPrettyFormat(), not XmlService .getPrettyFormat(), XmlService.getPrettyFormat (), or XmlService . getPrettyFormat().
- Wrong capitalization. Use XmlService and getPrettyFormat, not xmlservice or getprettyformat.
Explore
Related methods
-
.parse()
Parses an XML string into a document object.
-
.createElement()
Creates a new XML element with a tag name.
-
.createDocument()
Creates a new empty XML document.
More Apps Script
Better Sheets tutorials
No tagged tutorials yet. Fetch Apps Script from the harvest table and this page fills automatically.