XML
Module | ejs |
Definition | final class XML |
Inheritance | XML ![]() |
The XML class provides a simple ability to load, parse and save XML documents.
Properties
(No own properties defined)
XML Class Methods
Qualifiers | Method |
---|
XML Instance Methods
Qualifiers | Method |
---|---|
XML(value: Object = null) | |
XML Constructor. | |
appendChild(child: XML): XML | |
Append a child to this XML object. | |
attribute(name: String): XMLList | |
Get an XMLList containing all of the attributes of this object with the given name. | |
attributes(): XMLList | |
Get an XMLList containing all of the attributes of this object. | |
descendants(name: String = *): Object | |
Get all the descendants of this XML object with a given name. | |
child(name: String): XMLList | |
Get an XMLList containing the list of children (properties) in this XML object with the given name. | |
childIndex(): Number | |
Get the position of this object within the context of its parent. | |
children(): XMLList | |
Get an XMLList containing the children (properties) of this object in order. | |
contains(obj: Object): Boolean | |
Compare an XML object to another one or an XMLList with only one XML object in it. | |
copy(): XML | |
Deep copy an XML object. | |
elements(name: String = *): XMLList | |
Get all the children of this XML node that are elements having the given name. | |
iterator override | get(): Iterator |
Get an iterator for this node to be used by "for (v in node)". | |
iterator override | getValues(): Iterator |
Get an iterator for this node to be used by "for each (v in node)". | |
hasComplexContent(): Boolean | |
Determine whether this XML object has complex content. | |
hasSimpleContent(): Boolean | |
Determine whether this XML object has simple content. | |
override | hasOwnProperty(name: String): Boolean |
Determine whether this object has its own property of the given name. | |
load(filename: String): Void | |
Load an XML document. | |
length(): Number | |
Return the length of an XML object in elements. | |
name(): String | |
Get the qualified name of this XML object. | |
parent(): XML | |
Get the parent of this XML object. | |
save(filename: String): Void | |
Save the XML object to a file. | |
override | toJSON(): String |
Convert to a JSON encoding. | |
override | toString(): String |
Provides a string representation of the XML object. | |
override | valueOf(): XML |
Return this XML object. |
Method Detail
XML(value: Object = null)
- Description
- XML Constructor. Create an empty XML object.
- Parameters
value: Object An optional XML or XMLList object to clone. [default: null]
- Description
- Append a child to this XML object.
- Parameters
child: XML The child to add.
- Returns
- This object with the added child.
- Description
- 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).
attributes(): XMLList
- Description
- Get an XMLList containing all of the attributes of this object.
- Returns
- An XMLList with all the attributes (zero or more).
- Description
- Get all the descendants of this XML object with a given name. The optional argument defaults to getting all descendants.
- Parameters
name: String The (optional) name to search on. [default: *]
- Returns
- The list of descendants.
- Description
- 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).
childIndex(): Number
- Description
- Get the position of this object within the context of its parent.
- Returns
- A number with the zero-based position.
children(): XMLList
- Description
- Get an XMLList containing the children (properties) of this object in order.
- Returns
- An XMLList with all the properties.
- Description
- Compare an XML object to another one or an XMLList with only one XML object in it. If the comparison operator is true, then one object is said to contain the other.
- Returns
- True if this object contains the argument.
copy(): XML
- Description
- Deep copy an XML object. The new object has its parent set to null.
- Returns
- Then new XML object.
- Description
- Get all the children of this XML node that are elements having the given name. The optional argument defaults to getting all elements.
- Parameters
name: String The (optional) name to search on. [default: *]
- Returns
- The list of elements.
override iterator get(): Iterator
- Description
- Get an iterator for this node to be used by "for (v in node)".
- Returns
- An iterator object.
override iterator getValues(): Iterator
- Description
- Get an iterator for this node to be used by "for each (v in node)".
- Returns
- An iterator object.
hasComplexContent(): Boolean
- Description
- Determine whether this XML object has complex content. If the object has child elements it is considered complex.
- Returns
- True if this object has complex content.
hasSimpleContent(): Boolean
- Description
- Determine whether this XML object has simple content. 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.
- Description
- Determine whether this object has its own property of the given name.
- Parameters
name: String The property to look for.
- Returns
- True if this object does have that property.
- Description
- Load an XML document.
- Parameters
filename: String Name of the file containing the XML document to load.
length(): Number
- Description
- Return the length of an XML object in elements. NOTE: this is a method not a property.
- Returns
- A number indicating the number of child elements.
name(): String
- Description
- Get the qualified name of this XML object.
- Returns
- The qualified name.
parent(): XML
- Description
- Get the parent of this XML object.
- Returns
- The parent.
- Description
- Save the XML object to a file.
- Parameters
filename: String Name of the file to save the XML document to.
override toJSON(): String
- Description
- Convert to a JSON encoding.
- Returns
- A JSON string.
override toString(): String
- Description
- Provides a string representation of the XML object.
- Returns
- A string with the encoding.
override valueOf(): XML
- Description
- Return this XML object.
- Returns
- This object.