XML
| Module | ejs |
| Namespace | intrinsic |
| Definition | final class XML |
| Specified | Ecma-357. |
| Inheritance | XML Object |
The XML class, and the entire XML API, is based on ECMA-357, ECMAScript for XML (E4X).
The XML class is a core class in the E4X specification; it provides the ability to load, parse and save XML documents.
Properties
| Qualifiers | Property | Type | Description |
|---|---|---|---|
| public static | ignoreComments | Boolean | TODO - doc. |
| public static | ignoreProcessingInstructions | Boolean | |
| public static | ignoreWhitespace | Boolean | |
| public static | prettyIndent | Boolean | |
| public static | prettyPrinting | Boolean |
XML Methods
| Qualifiers | Method |
|---|---|
| public | addNamespace(ns: Namespace): XML |
| public | appendChild(child: XML): XML |
| Append a child to this XML object. | |
| public | attribute(name: String): XMLList |
| Get an XMLList containing all of the attributes of this object with the given name. | |
| public | attributes(): XMLList |
| Get an XMLList containing all of the attributes of this object. | |
| public | child(name: String): XMLList |
| Get an XMLList containing the list of children (properties) in this XML object with the given name. | |
| public | childIndex(): Number |
| Get the position of this object within the context of its parent. | |
| public | children(): XMLList |
| Get an XMLList containing the children (properties) of this object in order. | |
| public | comments(): XMLList |
| Get an XMLList containing the properties of this object that are comments. | |
| public | contains(obj: Object): Boolean |
| Compare an XML object to another one or an XMLList with only one XML object in it. | |
| public | copy(): XML |
| Deep copy an XML object. | |
| public | defaultSettings(): Object |
| Get the defaults settings for an XML object. | |
| public | descendants(name: String): Object |
| Get all the descendants (that have the same name) of this XML object. | |
| public | elements(name: String): XMLList |
| Get all the children of this XML node that are elements having the given name. | |
| iterator override | get(deep: Boolean): Iterator |
| Get an iterator for this node to be used by "for (v in node)". | |
| iterator override | getValues(deep: Boolean): Iterator |
| Get an iterator for this node to be used by "for each (v in node)". | |
| public | hasComplexContent(): Boolean |
| Determine whether this XML object has complex content. | |
| public | hasSimpleContent(): Boolean |
| Determine whether this XML object has simple content. | |
| public | inScopeNamespaces(): Array |
| public | insertChildAfter(marker: Object, child: Object): XML |
| Insert a child object into an XML object immediately after a specified marker object. | |
| public | insertChildBefore(marker: Object, child: Object): XML |
| Insert a child object into an XML object immediately before a specified marker object. | |
| public override | length(): Number |
| Return the length of an XML object; the length is defined as 1. | |
| public | load(filename: String): Void |
| public | localName(): String |
| Get the local name portion of the complete name of this XML object. | |
| public | name(): String |
| Get the qualified name of this XML object. | |
| public | namespace(prefix: String): Object |
| public | namespaceDeclarations(): Array |
| public | nodeKind(): String |
| Get the kind of node this XML object is. | |
| public | normalize(): XML |
| Merge adjacent text nodes into one text node and eliminate empty text nodes. | |
| public | parent(): XML |
| Get the parent of this XML object. | |
| public | prependChild(child: Object): XML |
| Insert a child object into an XML object immediately before all existing properties. | |
| public | processingInstructions(name: String): XMLList |
| Get all the children of this XML node that are processing instructions having the given name. | |
| public | replace(property: Object, value: Object): Void |
| Change the value of a property. | |
| public | save(filename: String): Void |
| public | setChildren(properties: Object): XML |
| Replace all the current properties of this XML object with a new set. | |
| public | setLocalName(name: String): Void |
| Set the local name portion of the complete name of this XML object. | |
| public | setName(name: String): Void |
| Set the qualified name of this XML object. | |
| public | setSettings(settings: Object): Void |
| Configure the settings for this XML object. | |
| public | settings(): Object |
| Get the settings for this XML object. | |
| public | text(name: String): XMLList |
| Get all the properties of this XML node that are text nodes having the given name. | |
| public override | toJSON(): String |
| Convert to a JSON encoding. | |
| public override | toString(): String |
| Provides a string representation of the XML object. | |
| public | toXMLString(): String |
| Provides an XML-encoded version of the XML object that includes the tags. | |
| XML(value: Object) | |
| XML Constructor. |
Method Detail
Append a child to this XML object.
- Parameters
child: XML The child to add.
- Returns
- This object with the added child.
Get an XMLList containing all of the attributes of this object with the given name.
- Parameters
name: String The name to search on.
- Returns
- An XMLList with all the attributes (zero or more).
Get an XMLList containing all of the attributes of this object.
- Returns
- An XMLList with all the attributes (zero or more).
Get an XMLList containing the list of children (properties) in this XML object with the given name.
- Parameters
name: String The name to search on.
- Returns
- An XMLList with all the children names (zero or more).
Get the position of this object within the context of its parent.
- Returns
- A number with the zero-based position.
Get an XMLList containing the children (properties) of this object in order.
- Returns
- An XMLList with all the properties.
Get an XMLList containing the properties of this object that are comments.
- Returns
- An XMLList with all the comment properties.
Compare an XML object to another one or an XMLList with only one XML object in it.
- Description
- If the comparison operator is true, then one object is said to contain the other.
- Returns
- True if this object contains the argument.
Deep copy an XML object.
- Description
- The new object has its parent set to null.
- Returns
- Then new XML object.
Get the defaults settings for an XML object.
- Description
- The settings include boolean values for: ignoring comments, ignoring processing instruction, ignoring white space and pretty printing and indenting. See ECMA-357 for details.
- Returns
- Get the settings for this XML object.
Get all the descendants (that have the same name) of this XML object.
- Description
- The optional argument defaults to getting all descendants.
- Parameters
name: String The (optional) name to search on.
- Returns
- The list of descendants.
Get all the children of this XML node that are elements having the given name.
- Description
- The optional argument defaults to getting all elements.
- Parameters
name: String The (optional) name to search on.
- Returns
- The list of elements.
Get an iterator for this node to be used by "for (v in node)".
- Parameters
deep: Boolean Follow the prototype chain. Only implemented in ECMA compliance mode.. [default: false]
- Returns
- An iterator object.
Get an iterator for this node to be used by "for each (v in node)".
- Parameters
deep: Boolean Follow the prototype chain. Only implemented in ECMA compliance mode.. [default: false]
- Returns
- An iterator object.
Determine whether this XML object has complex content.
- Description
- If the object has child elements it is considered complex.
- Returns
- True if this object has complex content.
Determine whether this XML object has simple content.
- Description
- If the object is a text node, an attribute node or an XML element that has no children it is considered simple.
- Returns
- True if this object has simple content.
Insert a child object into an XML object immediately after a specified marker object.
- Description
- If the marker object is null then the new object is inserted at the end. If the marker object is not found then the insertion is not made. TODO - if marker is null. Insert at beginning or end?.
- Parameters
marker: Object Insert the new element before this one. child: Object Child element to be inserted.
- Returns
- This XML object - modified or not.
Insert a child object into an XML object immediately before a specified marker object.
- Description
- If the marker object is null then the new object is inserted at the end. If the marker object is not found then the insertion is not made. TODO - if marker is null. Insert at beginning or end?.
- Parameters
marker: Object Insert the new element before this one. child: Object Child element to be inserted.
- Returns
- This XML object - modified or not.
Return the length of an XML object; the length is defined as 1.
- Returns
- 1.
Get the local name portion of the complete name of this XML object.
- Returns
- The local name.
Get the qualified name of this XML object.
- Returns
- The qualified name.
Get the kind of node this XML object is.
- Returns
- The node kind.
Merge adjacent text nodes into one text node and eliminate empty text nodes.
- Returns
- This XML object.
Get the parent of this XML object.
- Returns
- The parent.
Insert a child object into an XML object immediately before all existing properties.
- Parameters
child: Object Child element to be inserted.
- Returns
- This XML object - modified or not.
Get all the children of this XML node that are processing instructions having the given name.
- Description
- The optional argument defaults to getting all processing instruction nodes.
- Parameters
name: String The (optional) name to search on.
- Returns
- The list of processing instruction nodes.
Replace all the current properties of this XML object with a new set.
- Description
- The argument can be another XML object or an XMLList.
- Parameters
properties: Object The new property or properties.
- Returns
- This XML object.
Set the local name portion of the complete name of this XML object.
- Parameters
Configure the settings for this XML object.
- Parameters
settings: Object A "settings" object previously returned from a call to the "settings" method.
Get the settings for this XML object.
- Description
- The settings include boolean values for: ignoring comments, ignoring processing instruction, ignoring white space and pretty printing and indenting. See ECMA-357 for details.
- Returns
- Get the settings for this XML object.
Get all the properties of this XML node that are text nodes having the given name.
- Description
- The optional argument defaults to getting all text nodes.
- Parameters
name: String The (optional) name to search on.
- Returns
- The list of text nodes.
Convert to a JSON encoding.
- Returns
- A JSON string.
Provides a string representation of the XML object.
- Returns
- A string with the encoding.
Provides an XML-encoded version of the XML object that includes the tags.
- Returns
- A string with the encoding.
XML Constructor.
- Description
- Create an empty XML object.
- Parameters
value: Object An optional XML or XMLList object to clone.
- Returns
- An XML node object.