/** Module: XmlService */
type XmlService = typeof XmlService;
declare namespace XmlService {
/**
* Creates an unattached CDATASection node with the given value.
*
* @param text - the value to set
*
* @returns the newly created CDATASection node
*/
function createCdata(
text: string
): XmlService.Cdata
/**
* Creates an unattached Comment node with the given value.
*
* @param text - the value to set
*
* @returns the newly created Comment node
*/
function createComment(
text: string
): XmlService.Comment
/**
* Creates an unattached DocumentType node for the root Element node
* with the given name.
*
* @param elementName - the name of the root Element node to specify in the DocType
* declaration
*
* @returns the newly created DocumentType node
*/
function createDocType(
elementName: string
): XmlService.DocType
/**
* Creates an unattached DocumentType node for the root Element node
* with the given name, and the given system ID for the external subset data.
*
* @param elementName - the name of the root Element node to specify in the DocType
* declaration
* @param systemId - the system ID of the external subset data to set
*
* @returns the newly created DocumentType node
*/
function createDocType(
elementName: string,
systemId: string
): XmlService.DocType
/**
* Creates an unattached DocumentType node for the root Element node
* with the given name, and the given public ID and system ID for the external subset data.
*
* @param elementName - the name of the root Element node to specify in the DocType
* declaration
* @param publicId - the public ID of the external subset data to set
* @param systemId - the system ID of the external subset data to set
*
* @returns the newly created DocumentType node
*/
function createDocType(
elementName: string,
publicId: string,
systemId: string
): XmlService.DocType
/**
* Creates an empty XML document.
*
* @returns the newly created document
*/
function createDocument(): XmlService.Document
/**
* Creates an XML document with the given root Element node.
*
* @param rootElement - the root Element node to set
*
* @returns the newly created document
*/
function createDocument(
rootElement: XmlService.Element
): XmlService.Document
/**
* Creates an unattached Element node with the given local name and no namespace.
*
* @param name - the local name to set
*
* @returns the newly created Element node
*/
function createElement(
name: string
): XmlService.Element
/**
* Creates an unattached Element node with the given local name and namespace.
*
* @param name - the local name to set
* @param namespace - the namespace to set
*
* @returns the newly created Element node
*/
function createElement(
name: string,
namespace: XmlService.Namespace
): XmlService.Element
/**
* Creates an unattached Text node with the given value.
*
* @param text - the value to set
*
* @returns the newly created Text node
*/
function createText(
text: string
): XmlService.Text
/**
* Creates a Format object for outputting a compact XML document. The formatter
* defaults to UTF-8 encoding, no indentation, and no additional line breaks, but includes
* the XML declaration and its encoding.
*
*
* // Log an XML document in compact form.
* var xml = '<root><a><b>Text!</b><b>More text!</b></a></root>';
* var document = XmlService.parse(xml);
* var output = XmlService.getCompactFormat()
* .format(document);
* Logger.log(output);
*
*
* @returns the newly created formatter
*/
function getCompactFormat(): XmlService.Format
/**
* Creates a Namespace with the given URI.
*
* @param uri - the URI for the namespace
*
* @returns the newly created namespace
*/
function getNamespace(
uri: string
): XmlService.Namespace
/**
* Creates a Namespace with the given prefix and URI.
*
* @param prefix - the prefix for the namespace
* @param uri - the URI for the namespace
*
* @returns the newly created namespace
*/
function getNamespace(
prefix: string,
uri: string
): XmlService.Namespace
/**
* Creates a Namespace that represents the absence of a real namespace.
*
* @returns the newly created namespace
*/
function getNoNamespace(): XmlService.Namespace
/**
* Creates a Format object for outputting a human-readable XML document. The formatter
* defaults to UTF-8 encoding, two-space indentation, \r\n line separators after
* every node, and includes the XML declaration and its encoding.
*
*
* // Log an XML document in human-readable form.
* var xml = '<root><a><b>Text!</b><b>More text!</b></a></root>';
* var document = XmlService.parse(xml);
* var output = XmlService.getPrettyFormat()
* .format(document);
* Logger.log(output);
*
*
* @returns the newly created formatter
*/
function getPrettyFormat(): XmlService.Format
/**
* Creates a Format object for outputting a raw XML document. The formatter defaults to
* UTF-8 encoding, no indentation and no line breaks other than those provided in the XML
* document itself, and includes the XML declaration and its encoding.
*
*
* // Log an XML document in raw form.
* var xml = '<root><a><b>Text!</b><b>More text!</b></a></root>';
* var document = XmlService.parse(xml);
* var output = XmlService.getRawFormat()
* .format(document);
* Logger.log(output);
*
*
* @returns the newly created formatter
*/
function getRawFormat(): XmlService.Format
/**
* Creates a Namespace with the standard xml prefix.
*
* @returns the newly created namespace
*/
function getXmlNamespace(): XmlService.Namespace
/**
* Creates an Document from the given XML, without validating the XML.
*
*
* var xml = '<root><a><b>Text!</b><b>More text!</b></a></root>';
* var doc = XmlService.parse(xml);
*
*
* @param xml - the XML to parse
*
* @returns the newly created document
*/
function parse(
xml: string
): XmlService.Document
class Attribute {
private constructor();
/**
* Gets the local name of the attribute. If the attribute has a namespace prefix, use getNamespace().getPrefix() to get the prefix.
*
* @returns the local name of the attribute
*/
getName(): string
/**
* Gets the namespace for the attribute.
*
* @returns the namespace for the attribute
*/
getNamespace(): XmlService.Namespace
/**
* Gets the value of the attribute.
*
* @returns the value of the attribute
*/
getValue(): string
/**
* Sets the local name of the attribute. To set a namespace prefix for the attribute, use setNamespace(namespace) in conjunction with XmlService.getNamespace(prefix, uri).
*
* @param name - the local name to set
*
* @returns the attribute, for chaining
*/
setName(
name: string
): XmlService.Attribute
/**
* Sets the namespace for the attribute. The namespace must have a prefix.
*
* @param namespace - the namespace to set
*
* @returns the attribute, for chaining
*/
setNamespace(
namespace: XmlService.Namespace
): XmlService.Attribute
/**
* Sets the value of the attribute.
*
* @param value - the value to set
*
* @returns the attribute, for chaining
*/
setValue(
value: string
): XmlService.Attribute
}
class Cdata {
private constructor();
/**
* Appends the given text to any content that already exists in the node.
*
* @param text - the text to append to the node
*
* @returns the Text node, for chaining
*/
append(
text: string
): XmlService.Text
/**
* Detaches the node from its parent Element node. If the node does not have a parent,
* this method has no effect.
*
* @returns the detached node
*/
detach(): XmlService.Content
/**
* Gets the node's parent Element node. If the node does not have a parent, this method
* returns null.
*
* @returns the parent Element node
*/
getParentElement(): XmlService.Element
/**
* Gets the text value of the Text node.
*
* @returns the text value of the Text node
*/
getText(): string
/**
* Gets the text value of all nodes that are direct or indirect children of the node, in the order
* they appear in the document.
*
* @returns the text value of all nodes that are direct or indirect children of the node
*/
getValue(): string
/**
* Sets the text value of the Text node.
*
* @param text - the text value to set
*
* @returns the Text node, for chaining
*/
setText(
text: string
): XmlService.Text
}
class Comment {
private constructor();
/**
* Detaches the node from its parent Element node. If the node does not have a parent,
* this method has no effect.
*
* @returns the detached node
*/
detach(): XmlService.Content
/**
* Gets the node's parent Element node. If the node does not have a parent, this method
* returns null.
*
* @returns the parent Element node
*/
getParentElement(): XmlService.Element
/**
* Gets the text value of the Comment node.
*
* @returns the text value of the Comment node
*/
getText(): string
/**
* Gets the text value of all nodes that are direct or indirect children of the node, in the order
* they appear in the document.
*
* @returns the text value of all nodes that are direct or indirect children of the node
*/
getValue(): string
/**
* Sets the text value of the Comment node.
*
* @param text - the text value to set
*
* @returns the Comment node, for chaining
*/
setText(
text: string
): XmlService.Comment
}
class Content {
private constructor();
/**
* Casts the node as a CDATASection node for the purposes of autocomplete. If the
* node's ContentType is not already CDATA, this method returns null.
*
* @returns the CDATASection node
*/
asCdata(): XmlService.Cdata
/**
* Casts the node as a Comment node for the purposes of autocomplete. If the node's
* ContentType is not already COMMENT, this method returns null.
*
* @returns the Comment node, or null if the node's content type is not COMMENT
*/
asComment(): XmlService.Comment
/**
* Casts the node as a DocumentType node for the purposes of autocomplete. If
* the node's ContentType is not already DOCTYPE, this method returns null.
*
* @returns the DocumentType node
*/
asDocType(): XmlService.DocType
/**
* Casts the node as an Element node for the purposes of autocomplete. If the node's
* ContentType is not already ELEMENT, this method returns null.
*
* @returns the Element node
*/
asElement(): XmlService.Element
/**
* Casts the node as a EntityReference node for the purposes of autocomplete.
* If the node's ContentType is not already ENTITYREF, this method returns
* null.
*
* @returns the EntityReference node
*/
asEntityRef(): XmlService.EntityRef
/**
* Casts the node as a ProcessingInstruction node for the purposes of autocomplete. If
* the node's ContentType is not already PROCESSINGINSTRUCTION, this method
* returns null.
*
* @returns the ProcessingInstruction node
*/
asProcessingInstruction(): XmlService.ProcessingInstruction
/**
* Casts the node as a Text node for the purposes of autocomplete. If the node's ContentType is not already TEXT, this method returns null.
*
* @returns the Text node
*/
asText(): XmlService.Text
/**
* Detaches the node from its parent Element node. If the node does not have a parent,
* this method has no effect.
*
* @returns the detached node
*/
detach(): XmlService.Content
/**
* Gets the node's parent Element node. If the node does not have a parent, this method
* returns null.
*
* @returns the parent Element node
*/
getParentElement(): XmlService.Element
/**
* Gets the node's content type.
*
* @returns the node's content type
*/
getType(): XmlService.ContentType
/**
* Gets the text value of all nodes that are direct or indirect children of the node, in the order
* they appear in the document.
*
* @returns the text value of all nodes that are direct or indirect children of the node
*/
getValue(): string
}
enum ContentType {
/**
* An XML CDATASection node.
*/
CDATA = "CDATA",
/**
* An XML Comment node.
*/
COMMENT = "COMMENT",
/**
* An XML DocumentType node.
*/
DOCTYPE = "DOCTYPE",
/**
* An XML Element node.
*/
ELEMENT = "ELEMENT",
/**
* An XML EntityReference node.
*/
ENTITYREF = "ENTITYREF",
/**
* An XML ProcessingInstruction node.
*/
PROCESSINGINSTRUCTION = "PROCESSINGINSTRUCTION",
/**
* An XML Text node.
*/
TEXT = "TEXT",
}
class DocType {
private constructor();
/**
* Detaches the node from its parent Element node. If the node does not have a parent,
* this method has no effect.
*
* @returns the detached node
*/
detach(): XmlService.Content
/**
* Gets the name of the root Element node specified in the DocType declaration.
*
* @returns the name of the root Element node specified in the DocType declaration
*/
getElementName(): string
/**
* Gets the internal subset data for the DocumentType node.
*
* @returns the internal subset data
*/
getInternalSubset(): string
/**
* Gets the node's parent Element node. If the node does not have a parent, this method
* returns null.
*
* @returns the parent Element node
*/
getParentElement(): XmlService.Element
/**
* Gets the public ID of the external subset data for the DocumentType node.
*
* @returns the public ID of the external subset data
*/
getPublicId(): string
/**
* Gets the system ID of the external subset data for the DocumentType node.
*
* @returns the system ID of the external subset data
*/
getSystemId(): string
/**
* Gets the text value of all nodes that are direct or indirect children of the node, in the order
* they appear in the document.
*
* @returns the text value of all nodes that are direct or indirect children of the node
*/
getValue(): string
/**
* Sets the name of the root Element node to specify in the DocType
* declaration.
*
* @param name - the name of the root Element node to specify in the DocType
* declaration
*
* @returns the DocumentType node, for chaining
*/
setElementName(
name: string
): XmlService.DocType
/**
* Sets the internal subset data for the DocumentType node.
*
* @param data - the internal subset data to set
*
* @returns the DocumentType node, for chaining
*/
setInternalSubset(
data: string
): XmlService.DocType
/**
* Sets the public ID of the external subset data for the DocumentType node.
*
* @param id - the public ID of the external subset data to set
*
* @returns the DocumentType node, for chaining
*/
setPublicId(
id: string
): XmlService.DocType
/**
* Sets the system ID of the external subset data for the DocumentType node.
*
* @param id - the system ID of the external subset data to set
*
* @returns the DocumentType node, for chaining
*/
setSystemId(
id: string
): XmlService.DocType
}
class Document {
private constructor();
/**
* Inserts the given node at the given index among all nodes that are immediate children of the
* document. The content argument can be a Content object or any node object
* that corresponds to a type listed in ContentType. Note, however, that a document
* can only have one child Element node, which is implicitly the root Element
* node.
*
* @param index - the index at which to insert the node among all nodes that are immediate children
* of the document
* @param content - the node to insert
*
* @returns the document, for chaining
*/
addContent(
index: number,
content: XmlService.Content
): XmlService.Document
/**
* Appends the given node to the end of the document. The content argument can be a Content object or any node object that corresponds to a type listed in ContentType. Note, however, that a document can only have one child Element
* node, which is implicitly the root Element node.
*
* @param content - the node to append
*
* @returns the document, for chaining
*/
addContent(
content: XmlService.Content
): XmlService.Document
/**
* Creates unattached copies of all nodes that are immediate children of the document.
*
* @returns an array of unattached copies of all nodes that are immediate children of the
* document
*/
cloneContent(): XmlService.Content[]
/**
* Detaches and returns the document's root Element node. If the document does not have
* a root Element node, this method returns null.
*
* @returns the detached Element node, or null if the document does not have a root
* Element node
*/
detachRootElement(): XmlService.Element
/**
* Gets all nodes that are immediate children of the document.
*
* @returns an array of all nodes that are immediate children of the document
*/
getAllContent(): XmlService.Content[]
/**
* Gets the node at the given index among all nodes that are immediate children of the
* document. If there is no node at the given index, this method returns null.
*
* @param index - the index for the node among all nodes that are immediate children of the
* document
*
* @returns the node, or null if there is no node at the given index
*/
getContent(
index: number
): XmlService.Content
/**
* Gets the number of nodes that are immediate children of the document.
*
* @returns the number of nodes that are immediate children of the document
*/
getContentSize(): number
/**
* Gets all nodes that are direct or indirect children of the document, in the order they
* appear in the document.
*
* @returns an array of all nodes that are direct or indirect children of the document
*/
getDescendants(): XmlService.Content[]
/**
* Gets the document's DocType declaration. If the document does not have a DocumentType node, this method returns null.
*
* @returns the DocumentType node, or null if the document does not have a DocumentType node
*/
getDocType(): XmlService.DocType
/**
* Gets the document's root Element node. If the document does not have a root Element node, this method returns null.
*
* @returns the root Element node, or null if the document does not have a root
* Element node
*/
getRootElement(): XmlService.Element
/**
* Determines whether the document has a root Element node.
*
* @returns true if the document has a root Element node; false if not
*/
hasRootElement(): Boolean
/**
* Removes all nodes that are immediate children of the document.
*
* @returns an array of all nodes that were immediate children of the document before they
* were removed
*/
removeContent(): XmlService.Content[]
/**
* Removes the node at the given index among all nodes that are immediate children of the
* document. If there is no node at the given index, this method returns null.
*
* @param index - the index for the node among all nodes that are immediate children of the
* document
*
* @returns the node that was removed, or null if there is no node at the given index
*/
removeContent(
index: number
): XmlService.Content
/**
* Removes the given node, if the node is an immediate child of the document. The content argument can be a Content object or any node object that corresponds to a
* type listed in ContentType.
*
* @param content - the node to remove
*
* @returns true if the node was an immediate child and was removed; false if not
*/
removeContent(
content: XmlService.Content
): Boolean
/**
* Sets the document's DocType declaration. If the document already has a different
* DocType node, this method overwrites the old node. This method throws an exception if
* the document already contains the same DocType node that is being set.
*
* @param docType - the DocumentType to set
*
* @returns the document, for chaining
*/
setDocType(
docType: XmlService.DocType
): XmlService.Document
/**
* Sets the document's root Element node. If the document already has a root Element node, this method overwrites the old node.
*
* @param element - the root Element node to set
*
* @returns the document, for chaining
*/
setRootElement(
element: XmlService.Element
): XmlService.Document
}
class Element {
private constructor();
/**
* Inserts the given node at the given index among all nodes that are immediate children of the
* Element node. The content argument can be a Element object or any
* node object that corresponds to a type listed in ContentType.
*
* @param index - the index at which to insert the node among all nodes that are immediate children
* of the Element node
* @param content - the node to insert
*
* @returns the Element node, for chaining
*/
addContent(
index: number,
content: XmlService.Content
): XmlService.Element
/**
* Appends the given node as the last child of the Element node. The content
* argument can be a Element object or any node object that corresponds to a type
* listed in ContentType.
*
* @param content - the node to append
*
* @returns the Element node, for chaining
*/
addContent(
content: XmlService.Content
): XmlService.Element
/**
* Creates unattached copies of all nodes that are immediate children of the {@code Element} node.
*
* @returns an array of unattached copies of all nodes that are immediate children of the
* {@code Element} node
*/
cloneContent(): XmlService.Content[]
/**
* Detaches the node from its parent Element node. If the node does not have a parent,
* this method has no effect.
*
* @returns the detached node
*/
detach(): XmlService.Content
/**
* Gets all nodes that are immediate children of the {@code Element} node.
*
* @returns an array of all nodes that are immediate children of the {@code Element} node
*/
getAllContent(): XmlService.Content[]
/**
* Gets the attribute for this Element node with the given name and no namespace. If there
* is no such attribute, this method returns null.
*
* @param name - the name of the attribute
*
* @returns the attribute, or null if there is no attribute with the given name and no
* namespace
*/
getAttribute(
name: string
): XmlService.Attribute
/**
* Gets the attribute for this Element node with the given name and namespace. If there is
* no such node, this method returns null.
*
* @param name - the name of the attribute
* @param namespace - the namespace of the attribute
*
* @returns the attribute, or null if there is no attribute with the given name and
* namespace
*/
getAttribute(
name: string,
namespace: XmlService.Namespace
): XmlService.Attribute
/**
* Gets all attributes for this Element node, in the order they appear in the document.
*
* @returns an array of all attributes for this Element node
*/
getAttributes(): XmlService.Attribute[]
/**
* Gets the first Element node with the given name and no namespace that is an immediate
* child of this Element node. If there is no such node, this method returns null.
*
* @param name - the name of the child Element node
*
* @returns the Element node, or null if there is no immediate child Element node with the given name and no namespace
*/
getChild(
name: string
): XmlService.Element
/**
* Gets the first Element node with the given name and namespace that is an immediate
* child of this Element node. If there is no such node, this method returns null.
*
* @param name - the name of the child Element node
* @param namespace - the namespace of the child Element node
*
* @returns the Element node, or null if there is no immediate child Element node with the given name and namespace
*/
getChild(
name: string,
namespace: XmlService.Namespace
): XmlService.Element
/**
* Gets the text value of the node with the given name and no namespace, if the node is an
* immediate child of the Element node. If there is no such node, this method returns
* null.
*
* @param name - the name of the child node
*
* @returns the text value of the child node, or null if there is no immediate child node
* with the given name and no namespace
*/
getChildText(
name: string
): string
/**
* Gets the text value of the node with the given name and namespace, if the node is an immediate
* child of the Element node. If there is no such node, this method returns null.
*
* @param name - the name of the child node
* @param namespace - the namespace of the child node
*
* @returns the text value of the child node, or null if there is no immediate child node
* with the given name and namespace
*/
getChildText(
name: string,
namespace: XmlService.Namespace
): string
/**
* Gets all Element nodes that are immediate children of this Element node, in the
* order they appear in the document.
*
* @returns an array of all Element nodes that are immediate children of this Element node
*/
getChildren(): XmlService.Element[]
/**
* Gets all Element nodes with the given name and no namespace that are immediate children
* of this Element node, in the order they appear in the document.
*
* @param name - the name of the child Element nodes
*
* @returns an array of all Element nodes with the given name and no namespace that are
* immediate children of this Element node
*/
getChildren(
name: string
): XmlService.Element[]
/**
* Gets all Element nodes with the given name and namespace that are immediate children of
* this Element node, in the order they appear in the document.
*
* @param name - the name of the child Element nodes
* @param namespace - the namespace of the child Element nodes
*
* @returns an array of all Element nodes with the given name and namespace that are
* immediate children of this Element node
*/
getChildren(
name: string,
namespace: XmlService.Namespace
): XmlService.Element[]
/**
* Gets the node at the given index among all nodes that are immediate children of the
* {@code Element} node. If there is no node at the given index, this method returns null.
*
* @param index - the index for the node among all nodes that are immediate children of the
* {@code Element} node
*
* @returns the node, or null if there is no node at the given index
*/
getContent(
index: number
): XmlService.Content
/**
* Gets the number of nodes that are immediate children of the {@code Element} node.
*
* @returns the number of nodes that are immediate children of the {@code Element} node
*/
getContentSize(): number
/**
* Gets all nodes that are direct or indirect children of the {@code Element} node, in the order they
* appear in the document.
*
* @returns an array of all nodes that are direct or indirect children of the {@code Element} node
*/
getDescendants(): XmlService.Content[]
/**
* Gets the XML document that contains the {@code Element} node.
*
* @returns the document that contains the {@code Element} node
*/
getDocument(): XmlService.Document
/**
* Gets the local name of the Element node. If the node has a namespace prefix, use getQualifiedName() or getNamespace().getPrefix() to
* get the prefix.
*
* @returns the local name of the Element node
*/
getName(): string
/**
* Gets the namespace for the Element node.
*
* @returns the namespace for the Element node
*/
getNamespace(): XmlService.Namespace
/**
* Gets the namespace with the given prefix for the Element node.
*
* @param prefix - the prefix for the namespace
*
* @returns the namespace with the given prefix for the Element node
*/
getNamespace(
prefix: string
): XmlService.Namespace
/**
* Gets the node's parent Element node. If the node does not have a parent, this method
* returns null.
*
* @returns the parent Element node
*/
getParentElement(): XmlService.Element
/**
* Gets the local name and namespace prefix of the Element node, in the form [namespacePrefix]:[localName]. If the node does not have a namespace prefix, use getName().
*
* @returns the local name and namespace prefix of the Element node, in the form [namespacePrefix]:[localName]
*/
getQualifiedName(): string
/**
* Gets the text value of the Element node.
*
* @returns the text value of the Element node
*/
getText(): string
/**
* Gets the text value of all nodes that are direct or indirect children of the node, in the order
* they appear in the document.
*
* @returns the text value of all nodes that are direct or indirect children of the node
*/
getValue(): string
/**
* Determines whether this Element node is a direct or indirect parent of a given Element node.
*
* @param other - the other Element node
*
* @returns true if this Element node is a direct or indirect parent of the given
* Element node; false if not
*/
isAncestorOf(
other: XmlService.Element
): Boolean
/**
* Determines whether the Element node is the document's root node.
*
* @returns true if the Element node is the document's root node; false if
* not
*/
isRootElement(): Boolean
/**
* Removes the attribute for this Element node with the given name and no namespace, if
* such an attribute exists.
*
* @param attributeName - the name of the attribute
*
* @returns true if the attribute existed and was removed; false if not
*/
removeAttribute(
attributeName: string
): Boolean
/**
* Removes the attribute for this Element node with the given name and namespace, if such
* an attribute exists.
*
* @param attributeName - the name of the attribute
* @param namespace - the namespace of the attribute
*
* @returns true if the attribute existed and was removed; false if not
*/
removeAttribute(
attributeName: string,
namespace: XmlService.Namespace
): Boolean
/**
* Removes the given attribute for this Element node, if such an attribute exists.
*
* @param attribute - the attribute
*
* @returns true if the attribute existed and was removed; false if not
*/
removeAttribute(
attribute: XmlService.Attribute
): Boolean
/**
* Removes all nodes that are immediate children of the {@code Element} node.
*
* @returns an array of all nodes that were immediate children of the {@code Element} node before they
* were removed
*/
removeContent(): XmlService.Content[]
/**
* Removes the node at the given index among all nodes that are immediate children of the
* {@code Element} node. If there is no node at the given index, this method returns null.
*
* @param index - the index for the node among all nodes that are immediate children of the
* {@code Element} node
*
* @returns the node that was removed, or null if there is no node at the given index
*/
removeContent(
index: number
): XmlService.Content
/**
* Removes the given node, if the node is an immediate child of the {@code Element} node. The content argument can be a Element object or any node object that corresponds to a
* type listed in ContentType.
*
* @param content - the node to remove
*
* @returns true if the node was an immediate child and was removed; false if not
*/
removeContent(
content: XmlService.Content
): Boolean
/**
* Sets the attribute for this Element node with the given name, value, and no namespace.
*
* @param name - the name of the attribute to set
* @param value - the value of the attribute to set
*
* @returns the Element node, for chaining
*/
setAttribute(
name: string,
value: string
): XmlService.Element
/**
* Sets the attribute for this Element node with the given name, value, and namespace.
*
* @param name - the name of the attribute to set
* @param value - the value of the attribute to set
* @param namespace - the namespace of the attribute to set
*
* @returns the Element node, for chaining
*/
setAttribute(
name: string,
value: string,
namespace: XmlService.Namespace
): XmlService.Element
/**
* Sets the given attribute for this Element node.
*
* @param attribute - the attribute to set
*
* @returns the Element node, for chaining
*/
setAttribute(
attribute: XmlService.Attribute
): XmlService.Element
/**
* Sets the local name of the Element node. To set a namespace prefix for the node, use
* setNamespace(namespace) in conjunction with XmlService.getNamespace(prefix, uri).
*
* @param name - the local name to set
*
* @returns the Element node, for chaining
*/
setName(
name: string
): XmlService.Element
/**
* Sets the namespace for the Element node.
*
* @param namespace - the namespace to set
*
* @returns the Element node, for chaining
*/
setNamespace(
namespace: XmlService.Namespace
): XmlService.Element
/**
* Sets the text value of the Element node. If the node already contains a text value or
* any child nodes, this method overwrites the old content. To append or insert content instead,
* use addContent(content) or addContent(index, content).
*
* @param text - the text to set
*
* @returns the Element node, for chaining
*/
setText(
text: string
): XmlService.Element
}
class EntityRef {
private constructor();
/**
* Detaches the node from its parent Element node. If the node does not have a parent,
* this method has no effect.
*
* @returns the detached node
*/
detach(): XmlService.Content
/**
* Gets the name of the EntityReference node.
*
* @returns the name of the EntityReference node
*/
getName(): string
/**
* Gets the node's parent Element node. If the node does not have a parent, this method
* returns null.
*
* @returns the parent Element node
*/
getParentElement(): XmlService.Element
/**
* Gets the public ID of the EntityReference node. If the node does not have a public ID,
* this method returns null.
*
* @returns the public ID of the EntityReference node, or null if it has none
*/
getPublicId(): string
/**
* Gets the system ID of the EntityReference node. If the node does not have a system ID,
* this method returns null.
*
* @returns the system ID of the EntityReference node, or null if it has none
*/
getSystemId(): string
/**
* Gets the text value of all nodes that are direct or indirect children of the node, in the order
* they appear in the document.
*
* @returns the text value of all nodes that are direct or indirect children of the node
*/
getValue(): string
/**
* Sets the name of the EntityReference node.
*
* @param name - the name to set
*
* @returns the EntityReference node, for chaining
*/
setName(
name: string
): XmlService.EntityRef
/**
* Sets the public ID of the EntityReference node.
*
* @param id - the public ID to set
*
* @returns the EntityReference node, for chaining
*/
setPublicId(
id: string
): XmlService.EntityRef
/**
* Sets the system ID of the EntityReference node.
*
* @param id - the system ID to set
*
* @returns the EntityReference node, for chaining
*/
setSystemId(
id: string
): XmlService.EntityRef
}
class Format {
private constructor();
/**
* Outputs the given Document as a formatted string.
*
* @param document - the document to format
*
* @returns the formatted document
*/
format(
document: XmlService.Document
): string
/**
* Outputs the given Element node as a formatted string.
*
* @param element - the element to format
*
* @returns the formatted element
*/
format(
element: XmlService.Element
): string
/**
* Sets the character encoding that the formatter should use. The encoding argument must
* be an accepted XML encoding like ISO-8859-1, US-ASCII, UTF-8, or UTF-16.
*
*
* // Log an XML document with encoding that does not support certain special characters.
* var xml = '<root><a><b>ಠ‿ಠ</b><b>ಠ‿ಠ</b></a></root>';
* var document = XmlService.parse(xml);
* var output = XmlService.getRawFormat()
* .setEncoding('ISO-8859-1')
* .format(document);
* Logger.log(output);
*
*
* @param encoding - the encoding to use
*
* @returns the formatter, for chaining
*/
setEncoding(
encoding: string
): XmlService.Format
/**
* Sets the string used to indent child nodes relative to their parents. Setting an indent other
* than null will cause the formatter to insert a line break after every node.
*
*
* // Log an XML document with each child node indented four spaces.
* var xml = '<root><a><b>Text!</b><b>More text!</b></a></root>';
* var document = XmlService.parse(xml);
* var output = XmlService.getCompactFormat()
* .setIndent(' ')
* .format(document);
* Logger.log(output);
*
*
* @param indent - the indent to use
*
* @returns the formatter, for chaining
*/
setIndent(
indent: string
): XmlService.Format
/**
* Sets the string to insert whenever the formatter would normally insert a line break. The three
* pre-defined formatters have different conditions under which they insert a line break. The
* default line separator is \r\n.
*
*
* // Log an XML document with several spaces and a pipe character in place of line breaks.
* var xml = '<root><a><b>Text!</b><b>More text!</b></a></root>';
* var document = XmlService.parse(xml);
* var output = XmlService.getRawFormat()
* .setLineSeparator(' | ')
* .format(document);
* Logger.log(output);
*
*
* @param separator - the separator to use
*
* @returns the formatter, for chaining
*/
setLineSeparator(
separator: string
): XmlService.Format
/**
* Sets whether the formatter should omit the XML declaration, such as <?xml version="1.0"
* encoding="UTF-8"?>.
*
* @param omitDeclaration - true to omit the XML declaration; false to include it
*
* @returns the formatter, for chaining
*/
setOmitDeclaration(
omitDeclaration: Boolean
): XmlService.Format
/**
* Sets whether the formatter should omit the encoding in the XML declaration, such as the
* encoding field in <?xml version="1.0" encoding="UTF-8"?>.
*
* @param omitEncoding - true to omit the encoding in the XML declaration; false to
* include it
*
* @returns the formatter, for chaining
*/
setOmitEncoding(
omitEncoding: Boolean
): XmlService.Format
}
class Namespace {
private constructor();
/**
* Gets the prefix for the namespace.
*
* @returns the prefix for the namespace
*/
getPrefix(): string
/**
* Gets the URI for the namespace.
*
* @returns the URI for the namespace
*/
getURI(): string
}
class ProcessingInstruction {
private constructor();
/**
* Detaches the node from its parent Element node. If the node does not have a parent,
* this method has no effect.
*
* @returns the detached node
*/
detach(): XmlService.Content
/**
* Gets the raw data for every instruction in the ProcessingInstruction node.
*
* @returns the raw data for every instruction in the ProcessingInstruction node
*/
getData(): string
/**
* Gets the node's parent Element node. If the node does not have a parent, this method
* returns null.
*
* @returns the parent Element node
*/
getParentElement(): XmlService.Element
/**
* Gets the target for the ProcessingInstruction node.
*
* @returns the target for the ProcessingInstruction node
*/
getTarget(): string
/**
* Gets the text value of all nodes that are direct or indirect children of the node, in the order
* they appear in the document.
*
* @returns the text value of all nodes that are direct or indirect children of the node
*/
getValue(): string
}
class Text {
private constructor();
/**
* Appends the given text to any content that already exists in the node.
*
* @param text - the text to append to the node
*
* @returns the Text node, for chaining
*/
append(
text: string
): XmlService.Text
/**
* Detaches the node from its parent Element node. If the node does not have a parent,
* this method has no effect.
*
* @returns the detached node
*/
detach(): XmlService.Content
/**
* Gets the node's parent Element node. If the node does not have a parent, this method
* returns null.
*
* @returns the parent Element node
*/
getParentElement(): XmlService.Element
/**
* Gets the text value of the Text node.
*
* @returns the text value of the Text node
*/
getText(): string
/**
* Gets the text value of all nodes that are direct or indirect children of the node, in the order
* they appear in the document.
*
* @returns the text value of all nodes that are direct or indirect children of the node
*/
getValue(): string
/**
* Sets the text value of the Text node.
*
* @param text - the text value to set
*
* @returns the Text node, for chaining
*/
setText(
text: string
): XmlService.Text
}
}