com.gargoylesoftware.htmlunit.activex.javascript.msxml
Class XMLDOMNode

java.lang.Object
  extended by net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
      extended by com.gargoylesoftware.htmlunit.javascript.SimpleScriptable
          extended by com.gargoylesoftware.htmlunit.activex.javascript.msxml.MSXMLScriptable
              extended by com.gargoylesoftware.htmlunit.activex.javascript.msxml.XMLDOMNode
All Implemented Interfaces:
Serializable, Cloneable, net.sourceforge.htmlunit.corejs.javascript.ConstProperties, net.sourceforge.htmlunit.corejs.javascript.debug.DebuggableObject, net.sourceforge.htmlunit.corejs.javascript.Scriptable
Direct Known Subclasses:
XMLDOMAttribute, XMLDOMCharacterData, XMLDOMDocument, XMLDOMDocumentFragment, XMLDOMDocumentType, XMLDOMElement, XMLDOMProcessingInstruction

public class XMLDOMNode
extends MSXMLScriptable

A JavaScript object for MSXML's (ActiveX) XMLDOMNode.
Extends the core node with support for data types, namespaces, document type definitions (DTDs), and schemas.

Version:
$Revision: 9017 $
Author:
Mike Bowler, David K. Taylor, Barnaby Court, Christian Sell, George Murnock, Chris Erskine, Bruce Faulkner, Ahmed Ashour, Ronald Brill, Frank Danek
See Also:
MSDN documentation, Serialized Form

Field Summary
 
Fields inherited from class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
 
Fields inherited from interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
NOT_FOUND
 
Constructor Summary
XMLDOMNode()
          Creates an instance.
 
Method Summary
 Object appendChild(Object newChild)
          Appends a new child as the last child of the node.
 Object cloneNode(boolean deep)
          Clones a new node.
 Object getAttributes()
          Returns the list of attributes for this node.
 String getBaseName()
          Returns the base name for the name qualified with the namespace.
 XMLDOMNodeList getChildNodes()
          Returns a node list containing the child nodes.
 String getDataType()
          Returns the data type for this node.
 String getDefinition()
          Returns the definition of the node in the document type definition (DTD) or schema.
 XMLDOMNode getFirstChild()
          Returns the first child of this node.
protected  XMLDOMNode getJavaScriptNode(DomNode domNode)
          Gets the JavaScript node for a given DomNode.
 XMLDOMNode getLastChild()
          Returns the last child node.
 String getNamespaceURI()
          Returns the Uniform Resource Identifier (URI) for the namespace.
 XMLDOMNode getNextSibling()
          Returns the next sibling of this node in the parent's child list.
 String getNodeName()
          Returns the qualified name for attribute, document type, element, entity, or notation nodes.
 short getNodeType()
          Returns the XML Document Object Model (DOM) node type, which determines valid values and whether the node can have child nodes.
 String getNodeValue()
          Returns the text associated with the node.
 Object getOwnerDocument()
          Returns the root of the document that contains the node.
 Object getParentNode()
          Returns the parent node.
 String getPrefix()
          Returns the namespace prefix.
 XMLDOMNode getPreviousSibling()
          Returns the previous sibling of the node in the parent's child list.
 Object getText()
          Returns the text content of the node or the concatenated text representing the node and its descendants.
 Object getXml()
          Returns the XML representation of the node and all its descendants.
 boolean hasChildNodes()
          Provides a fast way to determine whether a node has children.
static Object insertBefore(net.sourceforge.htmlunit.corejs.javascript.Context context, net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, net.sourceforge.htmlunit.corejs.javascript.Function function)
          Inserts a child node to the left of the specified node, or at the end of the list.
protected  Object insertBeforeImpl(Object[] args)
          Inserts a child node to the left of the specified node, or at the end of the list.
 Object removeChild(Object childNode)
          Removes the specified child node from the list of children and returns it.
 Object replaceChild(Object newChild, Object oldChild)
          Replaces the specified old child node with the supplied new child node.
 XMLDOMSelection selectNodes(String expression)
          Applies the specified pattern-matching operation to this node's context and returns the list of matching nodes.
 Object selectSingleNode(String expression)
          Applies the specified pattern-matching operation to this node's context and returns the first matching node.
 void setNodeValue(String value)
          Sets the text associated with the node.
 void setText(Object text)
          Replace all child elements of this element by the supplied text.
 
Methods inherited from class com.gargoylesoftware.htmlunit.activex.javascript.msxml.MSXMLScriptable
getClassName, getEnvironment, getPrototype, makeScriptableFor, setEnvironment, setParentScope
 
Methods inherited from class com.gargoylesoftware.htmlunit.javascript.SimpleScriptable
clone, defineFunctionProperties, defineProperty, equivalentValues, get, getBrowserVersion, getDefaultValue, getDomNodeOrDie, getDomNodeOrNull, getScriptableFor, getStartingScope, getTransformerScriptableFor, getWindow, getWindow, getWithPreemption, hasInstance, initParentScope, isReadOnlySettable, setCaseSensitive, setDomNode, setDomNode, setHtmlElement
 
Methods inherited from class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setGetterOrSetter, setPrototype, size
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLDOMNode

public XMLDOMNode()
Creates an instance. JavaScript objects must have a default constructor.

Method Detail

getAttributes

public Object getAttributes()
Returns the list of attributes for this node.

Returns:
the list of attributes for this node

getBaseName

public String getBaseName()
Returns the base name for the name qualified with the namespace.

Returns:
the base name for the name qualified with the namespace

getChildNodes

public XMLDOMNodeList getChildNodes()
Returns a node list containing the child nodes.

Returns:
a node list containing the child nodes

getDataType

public String getDataType()
Returns the data type for this node.

Returns:
the data type for this node

getDefinition

public String getDefinition()
Returns the definition of the node in the document type definition (DTD) or schema.

Returns:
the definition of the node in the document type definition (DTD) or schema

getFirstChild

public XMLDOMNode getFirstChild()
Returns the first child of this node.

Returns:
the first child of this node

getLastChild

public XMLDOMNode getLastChild()
Returns the last child node.

Returns:
the last child node

getNamespaceURI

public String getNamespaceURI()
Returns the Uniform Resource Identifier (URI) for the namespace.

Returns:
the Uniform Resource Identifier (URI) for the namespace

getNextSibling

public XMLDOMNode getNextSibling()
Returns the next sibling of this node in the parent's child list.

Returns:
the next sibling of this node in the parent's child list

getNodeName

public String getNodeName()
Returns the qualified name for attribute, document type, element, entity, or notation nodes. Returns a fixed string for all other node types.

Returns:
the qualified name

getNodeType

public short getNodeType()
Returns the XML Document Object Model (DOM) node type, which determines valid values and whether the node can have child nodes.

Returns:
the XML Document Object Model (DOM) node type

getNodeValue

public String getNodeValue()
Returns the text associated with the node.

Returns:
the text associated with the node

setNodeValue

public void setNodeValue(String value)
Sets the text associated with the node.

Parameters:
value - the text associated with the node

getOwnerDocument

public Object getOwnerDocument()
Returns the root of the document that contains the node.

Returns:
the root of the document that contains the node

getParentNode

public Object getParentNode()
Returns the parent node.

Returns:
the parent node

getPrefix

public String getPrefix()
Returns the namespace prefix.

Returns:
the namespace prefix

getPreviousSibling

public XMLDOMNode getPreviousSibling()
Returns the previous sibling of the node in the parent's child list.

Returns:
the previous sibling of the node in the parent's child list

getText

public Object getText()
Returns the text content of the node or the concatenated text representing the node and its descendants.

Returns:
the text content of the node and its descendants

setText

public void setText(Object text)
Replace all child elements of this element by the supplied text.

Parameters:
text - the new text of this node

getXml

public Object getXml()
Returns the XML representation of the node and all its descendants.

Returns:
the XML representation of the node and all its descendants

appendChild

public Object appendChild(Object newChild)
Appends a new child as the last child of the node.

Parameters:
newChild - the new child node to be appended at the end of the list of children belonging to this node
Returns:
the new child node successfully appended to the list

cloneNode

public Object cloneNode(boolean deep)
Clones a new node.

Parameters:
deep - flag that indicates whether to recursively clone all nodes that are descendants of this node; if true, creates a clone of the complete tree below this node, if false, clones this node and its attributes only
Returns:
the newly created clone node

hasChildNodes

public boolean hasChildNodes()
Provides a fast way to determine whether a node has children.

Returns:
boolean true if this node has children

insertBefore

public static Object insertBefore(net.sourceforge.htmlunit.corejs.javascript.Context context,
                                  net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
                                  Object[] args,
                                  net.sourceforge.htmlunit.corejs.javascript.Function function)
Inserts a child node to the left of the specified node, or at the end of the list.

Parameters:
context - the JavaScript context
thisObj - the scriptable
args - the arguments passed into the method
function - the function
Returns:
on success, returns the child node that was inserted

insertBeforeImpl

protected Object insertBeforeImpl(Object[] args)
Inserts a child node to the left of the specified node, or at the end of the list.

Parameters:
args - the arguments
  • args[0]=newChild the new node to be inserted
  • args[1]=refChild the reference node; the newChild parameter is inserted to the left of the refChild parameter; if null, the newChild parameter is inserted at the end of the child list
Returns:
on success, returns the child node that was inserted

removeChild

public Object removeChild(Object childNode)
Removes the specified child node from the list of children and returns it.

Parameters:
childNode - the child node to be removed from the list of children of this node
Returns:
the removed child node

replaceChild

public Object replaceChild(Object newChild,
                           Object oldChild)
Replaces the specified old child node with the supplied new child node.

Parameters:
newChild - the new child that is to replace the old child; if null, oldChild is removed without a replacement
oldChild - the old child that is to be replaced by the new child
Returns:
the old child that is replaced

selectNodes

public XMLDOMSelection selectNodes(String expression)
Applies the specified pattern-matching operation to this node's context and returns the list of matching nodes.

Parameters:
expression - a string specifying an XPath expression
Returns:
the collection of nodes selected by applying the given pattern-matching operation; if no nodes are selected, returns an empty collection

selectSingleNode

public Object selectSingleNode(String expression)
Applies the specified pattern-matching operation to this node's context and returns the first matching node.

Parameters:
expression - a string specifying an XPath expression
Returns:
the first node that matches the given pattern-matching operation; if no nodes match the expression, returns null

getJavaScriptNode

protected XMLDOMNode getJavaScriptNode(DomNode domNode)
Gets the JavaScript node for a given DomNode.

Parameters:
domNode - the DomNode
Returns:
the JavaScript node or null if the DomNode was null


Copyright © 2002–2014 Gargoyle Software Inc.. All rights reserved.