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

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
                  extended by com.gargoylesoftware.htmlunit.activex.javascript.msxml.XMLDOMDocument
All Implemented Interfaces:
Serializable, Cloneable, net.sourceforge.htmlunit.corejs.javascript.ConstProperties, net.sourceforge.htmlunit.corejs.javascript.debug.DebuggableObject, net.sourceforge.htmlunit.corejs.javascript.Scriptable

public class XMLDOMDocument
extends XMLDOMNode

A JavaScript object for MSXML's (ActiveX) XMLDOMDocument.
Represents the top level of the XML source. Includes members for retrieving and creating all other XML objects.

Version:
$Revision: 9017 $
Author:
Ahmed Ashour, Marc Guillemot, Sudhan Moghe, Ronald Brill, Chuck Dumont, 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
XMLDOMDocument()
          Creates a new instance.
XMLDOMDocument(WebWindow enclosingWindow)
          Creates a new instance, with associated XmlPage.
 
Method Summary
 Object appendChild(Object newChild)
          Appends a new child as the last child of the node.
 Object createAttribute(String name)
          Creates a new attribute with the specified name.
 Object createCDATASection(String data)
          Creates a CDATA section node that contains the supplied data.
 Object createComment(String data)
          Creates a comment node that contains the supplied data.
 Object createDocumentFragment()
          Creates an empty document fragment object.
 Object createElement(String tagName)
          Creates an element node using the specified name.
 Object createNode(Object type, String name, Object namespaceURI)
          Creates a node using the supplied type, name, and namespace.
 Object createProcessingInstruction(String target, String data)
          Creates a processing instruction node that contains the supplied target and data.
 Object createTextNode(String data)
          Creates a text node that contains the supplied data.
 boolean getAsync()
          Returns if asynchronous download is permitted.
 XMLDOMDocumentType getDoctype()
          Returns the document type node that specifies the DTD for this document.
 XMLDOMElement getDocumentElement()
          Returns the root element of the document.
 XMLDOMNodeList getElementsByTagName(String tagName)
          Returns a collection of elements that have the specified name.
 XMLDOMImplementation getImplementation()
          Returns the implementation object for the document.
 Object getOwnerDocument()
          Returns the root of the document that contains the node.
protected  SgmlPage getPage()
           
 XMLDOMParseError getParseError()
          Returns a parse error object that contains information about the last parsing error.
 boolean getPreserveWhiteSpace()
          Returns the default white space handling.
 String getProperty(String name)
          Retrieves the value of one of the second-level properties that are set either by default or using the setProperty(String, String) method.
 Object getText()
          Returns the text content of the node or the concatenated text representing the node and its descendants.
 String getUrl()
          Returns the URL for the last loaded XML document.
 String getXml()
          Returns the XML representation of the node and all its descendants.
protected  void initParentScope(DomNode domNode, SimpleScriptable scriptable)
          Initialize the parent scope of a newly created scriptable.
protected  Object insertBeforeImpl(Object[] args)
          Inserts a child node to the left of the specified node, or at the end of the list.
 boolean isPreserveWhiteSpaceDuringLoad()
           
 boolean load(String xmlSource)
          Loads an XML document from the specified location.
 boolean loadXML(String strXML)
          Loads an XML document using the supplied string.
 MSXMLScriptable makeScriptableFor(DomNode domNode)
          Builds a new the JavaScript object that corresponds to the specified object.
 Object nodeFromID(String id)
          Returns the node that matches the ID attribute.
 void setAsync(boolean async)
          Sets if asynchronous download is permitted.
 void setDocumentElement(XMLDOMElement element)
          Sets the root element of the document.
 void setNodeValue(String value)
          Attempting to set the value of documents generates an error.
 void setPreserveWhiteSpace(boolean preserveWhiteSpace)
          Set the default white space handling.
 void setProperty(String name, String value)
          This method is used to set second-level properties on the DOM object.
 void setText(Object text)
          Attempting to set the text of documents generates an error.
 
Methods inherited from class com.gargoylesoftware.htmlunit.activex.javascript.msxml.XMLDOMNode
cloneNode, getAttributes, getBaseName, getChildNodes, getDataType, getDefinition, getFirstChild, getJavaScriptNode, getLastChild, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getParentNode, getPrefix, getPreviousSibling, hasChildNodes, insertBefore, removeChild, replaceChild, selectNodes, selectSingleNode
 
Methods inherited from class com.gargoylesoftware.htmlunit.activex.javascript.msxml.MSXMLScriptable
getClassName, getEnvironment, getPrototype, 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, 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

XMLDOMDocument

public XMLDOMDocument()
Creates a new instance. JavaScript objects must have a default constructor.


XMLDOMDocument

public XMLDOMDocument(WebWindow enclosingWindow)
Creates a new instance, with associated XmlPage.

Parameters:
enclosingWindow - the window
Method Detail

getAsync

public boolean getAsync()
Returns if asynchronous download is permitted.

Returns:
if asynchronous download is permitted

setAsync

public void setAsync(boolean async)
Sets if asynchronous download is permitted.

Parameters:
async - if asynchronous download is permitted

getDoctype

public XMLDOMDocumentType getDoctype()
Returns the document type node that specifies the DTD for this document.

Returns:
the document type node that specifies the DTD for this document

getDocumentElement

public XMLDOMElement getDocumentElement()
Returns the root element of the document.

Returns:
the root element of the document

setDocumentElement

public void setDocumentElement(XMLDOMElement element)
Sets the root element of the document.

Parameters:
element - the root element of the document

getImplementation

public XMLDOMImplementation getImplementation()
Returns the implementation object for the document.

Returns:
the implementation object for the document

setNodeValue

public void setNodeValue(String value)
Attempting to set the value of documents generates an error.

Overrides:
setNodeValue in class XMLDOMNode
Parameters:
value - the new value to set

getOwnerDocument

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

Overrides:
getOwnerDocument in class XMLDOMNode
Returns:
the root of the document that contains the node

getParseError

public XMLDOMParseError getParseError()
Returns a parse error object that contains information about the last parsing error.

Returns:
a parse error object

getPreserveWhiteSpace

public boolean getPreserveWhiteSpace()
Returns the default white space handling.

Returns:
the default white space handling

setPreserveWhiteSpace

public void setPreserveWhiteSpace(boolean preserveWhiteSpace)
Set the default white space handling.

Parameters:
preserveWhiteSpace - the default white space handling

getText

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

Overrides:
getText in class XMLDOMNode
Returns:
the text content of the node and its descendants

setText

public void setText(Object text)
Attempting to set the text of documents generates an error.

Overrides:
setText in class XMLDOMNode
Parameters:
text - the new text of this node

getUrl

public String getUrl()
Returns the URL for the last loaded XML document.

Returns:
the URL for the last loaded XML document

getXml

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

Overrides:
getXml in class XMLDOMNode
Returns:
an XML representation of this node and all its descendants

appendChild

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

Overrides:
appendChild in class XMLDOMNode
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

createAttribute

public Object createAttribute(String name)
Creates a new attribute with the specified name.

Parameters:
name - the name of the new attribute object
Returns:
the new attribute object

createCDATASection

public Object createCDATASection(String data)
Creates a CDATA section node that contains the supplied data.

Parameters:
data - the value to be supplied to the new CDATA section object's nodeValue property
Returns:
the new CDATA section object

createComment

public Object createComment(String data)
Creates a comment node that contains the supplied data.

Parameters:
data - the value to be supplied to the new comment object's nodeValue property
Returns:
the new comment object

createDocumentFragment

public Object createDocumentFragment()
Creates an empty document fragment object.

Returns:
the new document fragment object

createElement

public Object createElement(String tagName)
Creates an element node using the specified name.

Parameters:
tagName - the name for the new element node
Returns:
the new element object or NOT_FOUND if the tag is not supported

createNode

public Object createNode(Object type,
                         String name,
                         Object namespaceURI)
Creates a node using the supplied type, name, and namespace.

Parameters:
type - a value that uniquely identifies the node type
name - the value for the new node's nodeName property
namespaceURI - the namespace URI. If specified, the node is created in the context of the namespaceURI parameter with the prefix specified on the node name. If the name parameter does not have a prefix, this is treated as the default namespace.
Returns:
the newly created node

createProcessingInstruction

public Object createProcessingInstruction(String target,
                                          String data)
Creates a processing instruction node that contains the supplied target and data.

Parameters:
target - the target part of the processing instruction
data - the rest of the processing instruction preceding the closing ?> characters
Returns:
the new processing instruction object

createTextNode

public Object createTextNode(String data)
Creates a text node that contains the supplied data.

Parameters:
data - the value to be supplied to the new text object's nodeValue property
Returns:
the new text object or NOT_FOUND if there is an error

getElementsByTagName

public XMLDOMNodeList getElementsByTagName(String tagName)
Returns a collection of elements that have the specified name.

Parameters:
tagName - the element name to find; the tagName value '*' returns all elements in the document
Returns:
a collection of elements that match the specified name

getProperty

public String getProperty(String name)
Retrieves the value of one of the second-level properties that are set either by default or using the setProperty(String, String) method.

Parameters:
name - the name of the property
Returns:
the property value

insertBeforeImpl

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

Overrides:
insertBeforeImpl in class XMLDOMNode
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

load

public boolean load(String xmlSource)
Loads an XML document from the specified location.

Parameters:
xmlSource - a URL that specifies the location of the XML file
Returns:
true if the load succeeded; false if the load failed

loadXML

public boolean loadXML(String strXML)
Loads an XML document using the supplied string.

Parameters:
strXML - the XML string to load into this XML document object; this string can contain an entire XML document or a well-formed fragment
Returns:
true if the load succeeded; false if the load failed

nodeFromID

public Object nodeFromID(String id)
Returns the node that matches the ID attribute.

Parameters:
id - the value of the ID to match
Returns:
since we are not processing DTD, this method always returns null

setProperty

public void setProperty(String name,
                        String value)
This method is used to set second-level properties on the DOM object.

Parameters:
name - the name of the property to be set
value - the value of the specified property

isPreserveWhiteSpaceDuringLoad

public boolean isPreserveWhiteSpaceDuringLoad()
Returns:
the preserveWhiteSpaceDuringLoad

getPage

protected SgmlPage getPage()
Returns:
the page that this document is modeling

makeScriptableFor

public MSXMLScriptable makeScriptableFor(DomNode domNode)
Builds a new the JavaScript object that corresponds to the specified object.

Overrides:
makeScriptableFor in class MSXMLScriptable
Parameters:
domNode - the DOM node for which a JS object should be created
Returns:
the JavaScript object

initParentScope

protected void initParentScope(DomNode domNode,
                               SimpleScriptable scriptable)
Initialize the parent scope of a newly created scriptable.

Overrides:
initParentScope in class SimpleScriptable
Parameters:
domNode - the DOM node for the script object
scriptable - the script object to initialize


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