Searching the Help
To search for information in the Help, type a word or phrase in the Search box. When you enter a group of words, OR is inferred. You can use Boolean operators to refine your search.
Results returned are case insensitive. However, results ranking takes case into account and assigns higher scores to case matches. Therefore, a search for "cats" followed by a search for "Cats" would return the same number of Help topics, but the order in which the topics are listed would be different.
Search for | Example | Results |
---|---|---|
A single word | cat
|
Topics that contain the word "cat". You will also find its grammatical variations, such as "cats". |
A phrase. You can specify that the search results contain a specific phrase. |
"cat food" (quotation marks) |
Topics that contain the literal phrase "cat food" and all its grammatical variations. Without the quotation marks, the query is equivalent to specifying an OR operator, which finds topics with one of the individual words instead of the phrase. |
Search for | Operator | Example |
---|---|---|
Two or more words in the same topic |
|
|
Either word in a topic |
|
|
Topics that do not contain a specific word or phrase |
|
|
Topics that contain one string and do not contain another | ^ (caret) |
cat ^ mouse
|
A combination of search types | ( ) parentheses |
|
- JavaScript object: XML
- JavaScript method: XML.addAttribute()
- JavaScript method: XML.addElement()
- JavaScript method: XML.appendNode()
- JavaScript method: XML.createNode()
- JavaScript method: XML.getAttributeNode()
- JavaScript method: XML.getAttributeValue()
- JavaScript method: XML.getDocumentElement()
- JavaScript method: XML.getFirstAttribute()
- JavaScript method: XML.getFirstChildElement()
- JavaScript method: XML.getName()
- JavaScript method: XML.getNextAttribute()
- JavaScript method: XML.getNextSiblingElement()
- JavaScript method: XML.getNodeName()
- JavaScript method: XML.getNodeType()
- JavaScript method: XML.getNodeValue()
- JavaScript method: XML.getParentNode()
- JavaScript method: XML.getPrefix()
- JavaScript method: XML.getQualifiedName()
- JavaScript method: XML.getText()
- JavaScript method: XML.getValue()
- JavaScript method: XML.importNode()
- JavaScript method: XML.isDocumentElement()
- JavaScript method: XML.removeAttribute()
- JavaScript method: XML.setAttributeValue()
- JavaScript method: XML.setContent()
- JavaScript method: XML.setNodeValue()
- JavaScript method: XML.setText()
- JavaScript method: XML.setValue()
- JavaScript method: XML.toXMLString()
- JavaScript method: XMLDoc.insertBefore()
JavaScript method: XML.getDocumentElement()
This method searches an XML object for the DOM document element (or "root" node). It creates an XML object containing the document element and all child elements from an XML object or XML string.
Note You cannot use this method on objects that you have converted using the toXMLString method.
Syntax
XML.getDocumentElement();
Arguments
There are no arguments for this method.
Return values
An XML object or null.
If successful, this method returns an XML object containing the document element and all of its child elements. This method returns null if applied to an empty or invalid XML object.
Example
This example displays the XML document element from four different input sources.
This example requires the following sample data:
- A valid XML object (for example, the list of currently logged on users stored in system.users)
- A valid XML string (for example,
<document><parent1><child1 attribute1=\"1\" /></parent1><parent2 /></document>
) - A noncompliant XML string (for example,
<document1><parent1 /></document1><document2><parent2 /></document2>
) - An empty XML object
/* Create variables to store XML objects and strings. * Use goodXML to store a valid XML string. * Use badXML to store any erroneous XML string, in this case a second document element. * Use xmlObject to store a valid XML object such as the system.users list * The script sets the content of xmlString to goodXML. * The script sets the content of xmlBad to badXML. * The script sets the content of xmlEmpty to an XML object. */ var goodXML = "<document><parent1><child1 attribute1=\"1\" /></parent1><parent2 /></document>" var badXML = "<document1><parent1 /></document1><document2><parent2 /></document2>" var xmlObject = system.users var xmlString = new XML(); xmlString = xmlString.setContent( goodXML ); var xmlBad = new XML(); xmlBad = xmlBad.setContent( badXML ); print( "The value of xmlBad is:\n" + xmlBad ); var xmlEmpty = new XML(); /* Create a function to execute the getDocumentElement method on the document argument. */ function getDocElem( document ) { var DocElem = document.getDocumentElement(); if ( DocElem != null ) { var DocElemName = DocElem.getNodeName(); print( "Success. Found the document element " + DocElemName + " in the following object: \n" + document ); return DocElem } else { print( "Error. Did not find document element in the following object: \n" + document ); return null } } /* Run the getDocElem and getDocElemName functions on four input sources. * Print the objects returned by each function. */ print( "Now searching for a document element in a valid XML object...\n" ); getDocElem( xmlObject ); print( "Now searching for a document element in a valid XML string...\n" ); getDocElem( xmlString ); print( "Now searching for a document element in a non-compliant XML string...\n" ); getDocElem( xmlBad ); print( "Now searching for a document element in an empty XML object...\n" ); getDocElem( xmlEmpty );