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