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.getNextAttribute()
This method returns an XML object representing the next attribute of the current node.
Syntax
XML.getNextAttribute(); getNextAttribute(Element)
Arguments
The following arguments are valid for this method:
Argument | Data type | Description |
---|---|---|
Element
|
String | This argument contains the name of the element you want the method to use as the starting position when searching for the first attribute. |
Return values
An XML object or null
.
The method returns an object representing the first attribute of the current node or returns null
if the XML object has no attributes.
Example
This example displays the first attribute of any element you select. The example allows you to select an element from two different input sources.
This example requires the following sample data:
- A local XML file (for example, C:\test.xml which contains
<document><parent1><child1 attribute1="a" /><child2 /></parent1><parent2><child3 /><child4 /></parent2></document>
) - A valid XML string (for example,
<document><parent1><child1 /><child2 attribute2=\"b\" attribute3=\"c\" /></parent1><parent2 /></document>
)
/* Create variables to store XML objects and strings. * Use XMLObject to store a valid XML object such as an XML file. * Use sourceXMLString to store a valid XML string. * The script sets the content of XMLString to sourceXMLString. * The script assigns values to the empty variables later on */ var XMLFile = new XML(); XMLFile = XMLFile.setContent( "C:\\test.xml", true ); var sourceXMLString = "<document><parent1><child1 /><child2 attribute2=\"b\" attribute3=\"c\" /></parent1><parent2 /></document>"; var XMLString = new XML(); XMLString = XMLString.setContent( sourceXMLString ); var XMLSource; var TargetNode; var searchResults; var attributeResults; /* Create a function that searches an XML object (node) for a particular * element (targetElem) and returns an XML object containing the element. * This function assumes that there is only one instance of the target * element in the source data. If it finds more than one element in the * data it only returns the first instance of the element. */ function findTargetElement( node, targetElem ) { var topNodeName = node.getNodeName(); while (node != null && node.getNodeName() != targetElem ) { var childNode = node.getFirstChildElement(); if (childNode == null) { childNode = node.getNextSiblingElement(); while (childNode == null) { node = node.getParentNode(); if ( node == null || topNodeName == node.getNodeName() ) { return null; } childNode = node.getNextSiblingElement(); } node = childNode; } else { node = childNode; } } return node; } /* Create a function to print the target element and search results */ function printFindResults( target, searchResult ) { if ( searchResult != null ) { var elementName = searchResult.getNodeName(); print( "Found element " + elementName + " in: \n" + searchResult + "\n" ); return searchResult } else { print( "Cannot find " + target ); return null } } /* Create a function to find the first attribute of the target element */ function findFirstAttribute( sourceObject, targetNode ) { var startingNode = findTargetElement( sourceObject, targetNode ) var firstAttribute = startingNode.getFirstAttribute(); if ( firstAttribute != null ) { return firstAttribute } else { return null } } /* Create a function to print the first attribute of the target element */ function printAttributeResults( target, searchResult ) { if ( searchResult != null ) { var attributeName = searchResult.getNodeName(); print( "The first attribute of " + target + " is: " + attributeName ); return searchResult } else { print( "There are no attributes of " + target ); return null } } /* Create a function to find the next attribute of the target element */ function findNextAttribute( sourceObject, targetNode ) { var startingNode = findTargetElement( sourceObject, targetNode ) var firstAttribute = startingNode.getFirstAttribute(); if ( firstAttribute != null ) { var nextAttribute = startingNode.getNextAttribute(); while ( nextAttribute != null ) { var attributeName = nextAttribute.getNodeName(); print( "The next attribute of " + targetNode + " is: " + attributeName ); nextAttribute = nextAttribute.getNextAttribute(); } print( "There are no more attributes of " + targetNode ); return targetNode } else { return null } } /* Set variable values for XMLFile and TargetNode. Run functions */ print( "Processing XML from XMLFile... \n" ); TargetNode = "child1" XMLSource = XMLFile print( "The target element we are looking for is: " + TargetNode ); searchResults = findTargetElement( XMLSource, TargetNode ); printFindResults( TargetNode, searchResults ); attributeResults = findFirstAttribute( XMLSource, TargetNode ); printAttributeResults( TargetNode, attributeResults ); findNextAttribute( XMLSource, TargetNode ); /* Set variable values for XMLFile and TargetNode. Run functions */ print( "Processing XML from XMLString... \n" ); TargetNode = "child2" XMLSource = XMLString print( "The target element we are looking for is: " + TargetNode ); searchResults = findTargetElement( XMLSource, TargetNode ); printFindResults( TargetNode, searchResults ); attributeResults = findFirstAttribute( XMLSource, TargetNode ); printAttributeResults( TargetNode, attributeResults ); findNextAttribute( XMLSource, TargetNode );
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: