Creates a new XML element with a tag name.
class XmlService method .createElement()
XmlService is the Apps Script service.
.createElement() is the method name you will see after a dot in your code.
What it does
Why it's used
- Add nodes when building XML by hand.
- Structure nested data for an integration.
Common errors
- Forgetting parentheses on createElement. Write XmlService.createElement(), not XmlService.createElement or createElement by itself.
- Skipping dots between chained calls. Each step needs a dot, like XmlService.createElement().
- Adding spaces where they do not belong. Write XmlService.createElement(), not XmlService .createElement(), XmlService.createElement (), or XmlService . createElement().
- Wrong capitalization. Use XmlService and createElement, not xmlservice or createelement.
Explore
Related methods
-
.createDocument()
Creates a new empty XML document.
-
.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.