XML
Overview
E4X (Ecma-357) XML global object. This is based on a deprecated/withdrawn standard.
Properties Summarized
If set to true, then comments in the XML are ignored when constructing new XML objects.
If set to true, then processing instructions are ignored when constructing new XML objects.
If set to true, then whitespace in the XML is ignored when constructing new XML objects.
The amount of positions used when indenting child nodes are relative to their parent if prettyPrinting is enabled.
If set to true, then toString() and toXMLString() methods will normalize the output to achieve a uniform appearance.
Methods Summarized
Takes one argument which can be a string with a namespace URI or a Namespace object and adds the argument to the in scope namespaces of this XML object.
Appends a new child at the end of this XML object's properties, the changed XML object is then returned.
Takes a single argument with the attribute name and returns an XMLList with attributes matching the argument.
Returns an XMLList with the attributes of this XML object which are in no namespace.
If the XML object has no parent then the special number NaN is returned, otherwise the ordinal position the object has in the context of its parent is returned.
Returns a deep copy of the XML object it is called on where the internal parent property is set to null
Returns an XMLList with the descendants matching the passed name argument or with all descendants if no argument is passed.
Returns an XMLList with the descendants matching the passed name argument or with all descendants if no argument is passed.
Takes one optional argument, the name of elements you are looking for, and returns an XMLList with all matching child elements.
Takes one optional argument, the name of elements you are looking for, and returns an XMLList with all matching child elements.
Returns false for XML objects of node kind 'text', 'attribute', 'comment', and 'processing-instruction'.
Returns true if the XML object the method is called on has a property of that name.
Returns an array of Namespace objects representing the namespace that are in scope for this XML object.
Takes two arguments, an existing child to insert after and the new child to be inserted.
Takes two arguments, an existing child to insert before and the new child to be inserted.
If no argument is passed to the method then it returns the namespace associated with the qualified name of this XML object.
If no argument is passed to the method then it returns the namespace associated with the qualified name of this XML object.
Returns an array with the namespace declarations associated with the XML object it is called on.
Iinserts the given value as the first child of the XML object and returns the XML object.
If no argument is passed in then the method returns an XMLList with all the children of the XML object which are processing instructions.
If no argument is passed in then the method returns an XMLList with all the children of the XML object which are processing instructions.
Returns true if the property name is '0' and false otherwise.
Removes the namespace from the in scope namespaces of this XML object if the namespace is not used for the qualified name of the object or its attributes.
Takes two arguments, the property name of the property / properties to be replaced, and the value to replace the properties.
void
Changes the namespace associated with the name of this XML object to the new namespace.
void
Allows the global XML settings to be adjusted or restored to their default values.
Properties Detailed
ignoreComments
If set to true, then comments in the XML are ignored when constructing new XML objects.
Type Boolean
Sample
ignoreProcessingInstructions
If set to true, then processing instructions are ignored when constructing new XML objects.
Type Boolean
Sample
ignoreWhitespace
If set to true, then whitespace in the XML is ignored when constructing new XML objects.
Type Boolean
Sample
prettyIndent
The amount of positions used when indenting child nodes are relative to their parent if prettyPrinting is enabled.
Type Boolean
Sample
prettyPrinting
If set to true, then toString() and toXMLString() methods will normalize the output to achieve a uniform appearance.
Type Boolean
Sample
Methods Detailed
addNamespace(namespaceToAdd)
Takes one argument which can be a string with a namespace URI or a Namespace object and adds the argument to the in scope namespaces of this XML object.
Parameters
String namespaceToAdd ;
Returns: XML
Sample
appendChild(childToAppend)
Appends a new child at the end of this XML object's properties, the changed XML object is then returned.
Parameters
XML childToAppend ;
Returns: XML
Sample
attribute(attributeName)
Takes a single argument with the attribute name and returns an XMLList with attributes matching the argument.
Parameters
String attributeName ;
Returns: XMLList
Sample
attributes()
Returns an XMLList with the attributes of this XML object which are in no namespace.
Returns: XMLList
Sample
child(propertyName)
Returns an XMLList with children matching the property name.
Parameters
String propertyName ;
Returns: XMLList
Sample
childIndex()
If the XML object has no parent then the special number NaN is returned, otherwise the ordinal position the object has in the context of its parent is returned.
Returns: Number
Sample
children()
Returns an XMLList with the child nodes of this XML object.
Returns: XMLList
Sample
comments()
Returns an XMLList with the comment nodes which are children of this XML object.
Returns: XMLList
Sample
contains(value)
Calling xmlObject.contains(value) yields the same result as the equality comparison xmlObject == value
Parameters
Object value ;
Returns: Boolean
Sample
copy()
Returns a deep copy of the XML object it is called on where the internal parent property is set to null
Returns: XML
Sample
defaultSettings()
Returns an object containing the default XML settings.
Returns: Object
Sample
descendants()
Returns an XMLList with the descendants matching the passed name argument or with all descendants if no argument is passed.
Returns: XMLList
Sample
descendants(name)
Returns an XMLList with the descendants matching the passed name argument or with all descendants if no argument is passed.
Parameters
String name ;
Returns: XMLList
Sample
elements()
Takes one optional argument, the name of elements you are looking for, and returns an XMLList with all matching child elements.
Returns: XMLList
Sample
elements(name)
Takes one optional argument, the name of elements you are looking for, and returns an XMLList with all matching child elements.
Parameters
String name ;
Returns: XMLList
Sample
hasComplexContent()
Returns false for XML objects of node kind 'text', 'attribute', 'comment', and 'processing-instruction'. For objects of kind 'element' it checks whether the element has at least one child element.
Returns: Boolean
Sample
hasOwnProperty(propertyName)
Returns true if the XML object the method is called on has a property of that name.
Parameters
String propertyName ;
Returns: Boolean
Sample
hasSimpleContent()
Returns true for XML objects of node kind text or attribute. For XML objects of node kind element it returns true if the element has no child elements and false otherwise. For other node kinds (comment, processing instruction) the method always returns false.
Returns: Boolean
Sample
inScopeNamespaces()
Returns an array of Namespace objects representing the namespace that are in scope for this XML object.
Returns: Array
Sample
insertChildAfter(childToInserAfter, childToInsert)
Takes two arguments, an existing child to insert after and the new child to be inserted. If the first argument is null then the second argument is inserted as the first child of this XML.
Parameters
Returns: XML
Sample
insertChildBefore(childToInsertBefore, childToInsert)
Takes two arguments, an existing child to insert before and the new child to be inserted. If the first argument is null then the child is inserted as the last child.
Parameters
Returns: XML
Sample
length()
This always returns 1. This is done to blur the distinction between an XML object and an XMLList containing exactly one value.
Returns: Number
Sample
localName()
returns the local name part if the XML object has a name.
Returns: String
Sample
name()
Returns the qualified name (a QName object) of the XML object it is called
Returns: QName
Sample
namespace()
If no argument is passed to the method then it returns the namespace associated with the qualified name of this XML object. If a prefix is passed to the method then it looks for a matching namespace in the in scope namespace of this XML object and returns it when found, otherwise undefined is returned.
Returns: Namespace
Sample
namespace(prefix)
If no argument is passed to the method then it returns the namespace associated with the qualified name of this XML object. If a prefix is passed to the method then it looks for a matching namespace in the in scope namespace of this XML object and returns it when found, otherwise undefined is returned.
Parameters
String prefix ;
Returns: Namespace
Sample
namespaceDeclarations()
Returns an array with the namespace declarations associated with the XML object it is called on.
Returns: Array
Sample
nodeKind()
Returns a string denoting the kind of node this XML object represents. Possible values: 'element', 'attribute', 'text', 'comment', 'processing-instruction'.
Returns: String
Sample
normalize()
Returns this XML object after normalizing all text content.
Returns: XML
Sample
parent()
Returns the parent XML object of this XML object or null if there is no parent.
Returns: XML
Sample
prependChild(childToPrepend)
Iinserts the given value as the first child of the XML object and returns the XML object.
Parameters
XML childToPrepend ;
Returns: XML
Sample
processingInstructions()
If no argument is passed in then the method returns an XMLList with all the children of the XML object which are processing instructions. If an argument is passed in then the method returns an XMLList with all children of the XML object which are processing instructions where the name matches the argument.
Returns: XMLList
Sample
processingInstructions(name)
If no argument is passed in then the method returns an XMLList with all the children of the XML object which are processing instructions. If an argument is passed in then the method returns an XMLList with all children of the XML object which are processing instructions where the name matches the argument.
Parameters
String name ;
Returns: XMLList
Sample
propertyIsEnumerable(propertyName)
Returns true if the property name is '0' and false otherwise.
Parameters
String propertyName ;
Returns: Boolean
Sample
removeNamespace(namespace)
Removes the namespace from the in scope namespaces of this XML object if the namespace is not used for the qualified name of the object or its attributes.
Parameters
Namespace namespace ;
Returns: XML
Sample
replace(propertyName, replacementValue)
Takes two arguments, the property name of the property / properties to be replaced, and the value to replace the properties.
Parameters
Returns: XML
Sample
setChildren(value)
Replaces all children of the XML object with this value. The method returns the XML object it is called on.
Parameters
Object value ;
Returns: XML
Sample
setLocalName(name)
Changes the local name of this XML object to the name passed in.
Parameters
String name ;
Returns: void
Sample
setName(name)
Replaces the name of this XML object with the name passed in.
Parameters
String name ;
Returns: void
Sample
setNamespace(namespace)
Changes the namespace associated with the name of this XML object to the new namespace.
Parameters
Namespace namespace ;
Returns: void
Sample
setSettings()
Allows the global XML settings to be adjusted or restored to their default values.
Returns: void
Sample
setSettings(settings)
Allows the global XML settings to be adjusted or restored to their default values.
Parameters
Object settings The new settings that should be applied globally to the XML object.
Returns: void
Sample
settings()
Returns an object containing the global XML settings.
Returns: Object
Sample
text()
Returns an XMLList with all the children of this XML object that represent text nodes.
Returns: XMLList
Sample
toString()
Returns a convenient string value of this XML object.
Returns: String
Sample
toXMLString()
Returns a string with the serialized XML markup for this XML object. XML.prettyPrinting and XML.prettyIndent settings affect the returned string.
Returns: String
Sample
valueOf()
The method simply returns the XML object it is called on.
Returns: XML
Sample
Last updated
Was this helpful?