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.setContent()
This method creates an XML object from a string or the contents of an external file. It always creates a valid XML document with a document element. The method removes any values outside the document element.
Note This method returns null if applied to an existing XML object because the header information ([C++ object XML] @nnnnnnnnnn - ) is not valid.
Syntax
XML.setContent( String ); setContent( "FilePath", IsFile );
Arguments
The following arguments are valid for this method:
Argument | Data type | Description |
---|---|---|
String
|
String | This argument specifies the text string you want the script to parse as on XML object. The string argument must contain a valid XML document with a document element. |
FilePath
|
String | This argument specifies the path to the XML document you want the script to parse an XML object. You must enclose the FilePath argument in quotation marks and use the true argument to indicate that the first argument is a file path and not a string value. |
IsFile
|
Boolean | This argument specifies whether the first argument is a string or a file path. A true value indicates the first argument is a file path. Any other value, including omitting the second argument, indicates that the first argument is a string. |
Return values
An XML object or null
.
The method returns an XML object if it parses the XML input and returns null
if it cannot parse the input.
Arguments
Use the toXMLString method to convert an XML object to an XML string.
Example
This example attempts to create an XML object from five different sources.
This example requires the following sample data:
- A valid XML string (for example,
<document><parent1><child1 attribute1=\"1\" /></parent1><parent2 /></document>
) - An XML string with more than one document element (for example,
<document1><parent1 /></document1><document2><parent2 /></document2>
) - A local XML file (for example, C:\test.xml which contains
<document><parent1><child1 attribute1="a" /><child2 /></parent1><parent2><child3 /><child4 /></parent2></document>
) - An existing XML object (for example, the list of currently logged on users stored in system.users)
- An XML object converted to a string (for example, the list of currently logged on users stored in system.users)
/* Create a function to execute the setContent method. * The function creates a new XML object xmlObj. * It sets the content of the XML object to the source argument. * The isFile argument determines if the source is an XML string or file path. * If setContent returns true, it prints an XML string and returns the XML object. * If setContent returns false, it prints the source and returns null. */ function setXML( source, isFile ) { var xmlObj = new XML(); if ( xmlObj.setContent( source, isFile ) ) { var xmlDoc = xmlObj.toXMLString(); print( "setContent succeeded! \n The XML document is: \n" + xmlDoc ); return xmlObj } else { print( "setContent failed. \n Could not parse the following input as XML: \n" + source ); return null } } /* Create variables to store your XML source objects. * Use xmlObject to test setting content to an XML object. * xmlObjectConverted converts xmlObject to an XML string. * Note: The toXMLstring method removes the object header information. * Use xmlString to test setting content to an XML string. * Note: You must use the backslash character to escape out quotation marks in your XML string. * Use xmlFile to test setting content to an XML file. */ var xmlString = "<document><parent1><child1 attribute1=\"1\" /></parent1><parent2 /></document>"; var xmlBad = "<document1><parent1 /></document1><document2><parent2 /></document2>" var xmlFile = "C:\\test.xml"; var xmlObject = system.users var xmlObjectConverted = xmlObject.toXMLString(); /* Note: You can omit the isFile argument when the content source is an XML string. * See the xmlString example below. */ print( "Testing setting content to a valid XML string...\n" ); setXML( xmlString ); print( "Testing setting content to an XML string with more than one document element...\n" ); print( "The non-compliant XML string before conversion is: \n" + xmlBad ); setXML( xmlBad ); print( "Testing setting content to an XML file...\n" ); setXML( xmlFile, true ); print( "Testing setting content to an existing XML object...\n" ); setXML( xmlObject, false ); print( "Testing setting content to an existing XML object converted to an XML string...\n" ); setXML( xmlObjectConverted, false );
We welcome your comments!
To open the configured email client on this computer, open an email window.
Otherwise, copy the information below to a web mail client, and send this email to docs.feedback@hpe.com.
Help Topic ID:
Product:
Topic Title:
Feedback: