Google Apps Script API
    Preparing search index...

    This service allows scripts to parse, navigate, and programmatically create XML documents.

    // Log the title and labels for the first page of blog posts on the G Suite Developer blog.
    function parseXml() {
      var url = 'https://gsuite-developers.googleblog.com/atom.xml';
      var xml = UrlFetchApp.fetch(url).getContentText();
      var document = XmlService.parse(xml);
      var root = document.getRootElement();
      var atom = XmlService.getNamespace('http://www.w3.org/2005/Atom');
    
      var entries = root.getChildren('entry', atom);
      for (var i = 0; i < entries.length; i++) {
        var title = entries[i].getChild('title', atom).getText();
        var categoryElements = entries[i].getChildren('category', atom);
        var labels = [];
        for (var j = 0; j < categoryElements.length; j++) {
          labels.push(categoryElements[j].getAttribute('term').getValue());
        }
        Logger.log('%s (%s)', title, labels.join(', '));
      }
    }
    
    // Create and log an XML representation of the threads in your Gmail inbox.
    function createXml() {
      var root = XmlService.createElement('threads');
      var threads = GmailApp.getInboxThreads();
      for (var i = 0; i < threads.length; i++) {
        var child = XmlService.createElement('thread')
            .setAttribute('messageCount', threads[i].getMessageCount())
            .setAttribute('isUnread', threads[i].isUnread())
            .setText(threads[i].getFirstMessageSubject());
        root.addContent(child);
      }
      var document = XmlService.createDocument(root);
      var xml = XmlService.getPrettyFormat().format(document);
      Logger.log(xml);
    }
    
    interface XmlService {
        ContentTypes: typeof GoogleAppsScript.XML_Service.ContentType;
        createCdata(text: string): Cdata;
        createComment(text: string): GoogleAppsScript.XML_Service.Comment;
        createDocType(elementName: string): DocType;
        createDocType(elementName: string, systemId: string): DocType;
        createDocType(
            elementName: string,
            publicId: string,
            systemId: string,
        ): DocType;
        createDocument(): GoogleAppsScript.XML_Service.Document;
        createDocument(
            rootElement: GoogleAppsScript.XML_Service.Element,
        ): GoogleAppsScript.XML_Service.Document;
        createElement(name: string): GoogleAppsScript.XML_Service.Element;
        createElement(
            name: string,
            namespace: Namespace,
        ): GoogleAppsScript.XML_Service.Element;
        createText(text: string): GoogleAppsScript.XML_Service.Text;
        getCompactFormat(): GoogleAppsScript.XML_Service.Format;
        getNamespace(uri: string): Namespace;
        getNamespace(prefix: string, uri: string): Namespace;
        getNoNamespace(): Namespace;
        getPrettyFormat(): GoogleAppsScript.XML_Service.Format;
        getRawFormat(): GoogleAppsScript.XML_Service.Format;
        getXmlNamespace(): Namespace;
        parse(xml: string): GoogleAppsScript.XML_Service.Document;
    }
    Index

    Properties

    Methods