DOMNamedNodeMap methods

The DOMNamedNodeMap interface supports the following methods:

getNamedItem(strName) 
Returns  DOMNode 
Description  Retrieves a DOMNode specified by strName. The names used to address nodes in a DOMNamedNodeMap are the same as those returned by the DOMNode.nodeName property . 
Usage 
JScript  DOMNamedNodeMap_object.getNamedItem("strName");  
VBScript  DOMNamedNodeMap_object.getNamedItem("strName") 
Example 
// SoftQuad Script Language JSCRIPT:
var mynodelist;
mynodelist = ActiveDocument.getElementsByTagname("*");
// grab the second node in the node list
var aNode = mynodelist.item(1);
// get the NamedNodeMap of attributes for this node.
var myNodeMap = aNode.attributes;  
// use the getNamedItem() method to obtain 
// the attribute node "Id"
var namedItem = myNodeMap.getNamedItem("Id");
Application.Alert(namedItem.nodeValue);
 

item(longIndex) 
Returns  DOMNode 
Description  Returns a DOMNode object indexed by longIndex in the DOMNamedNodeMap. Note that DOMNamedNodeMaps do not store the nodes in any particular order. The item method is provided as a convenient way to enumerate the DOMNamedNodeMap. Valid indexes range from 0 to length-1. 
Usage 
JScript  DOMNamedNodeMap_object.item(longIndex);  
VBScript  DOMNamedNodeMap_object.item(longIndex) 
Example 
// SoftQuad Script Language JSCRIPT:
var mynodelist;
mynodelist = ActiveDocument.getElementsByTagname("*");
// grab the second node in the node list
var aNode = mynodelist.item(1);
// get the NamedNodeMap of attributes for this node.
var myNodeMap = aNode.attributes;  
Application.Alert(myNodeMap.length);
// use the item() method to access the first attribute
Application.Alert(myNodeMap.item(0).nodeName);
 

removeNamedItem(strNodeName) 
Returns  DOMNode 
Description  Removes a DOMNode specified by strNodeName. If the removed node is a DOMAttr with a default value it is immediately replaced. Not implemented. 
Usage 
JScript  DOMNamedNodeMap_object.removeNamedItem("strNodeName");  
VBScript  DOMNamedNodeMap_object.removeNamedItem("strNodeName") 

setNamedItem(DOMNode) 
Returns  DOMNode 
Description  Adds a DOMNode to the DOMNamedNodeMap If the new node replaces an existing node with the same name, the previously existing node is returned; otherwise null is returned. Not implemented. 
Usage 
JScript  DOMNamedNodeMap_object.setNamedItem(DOMNode);  
VBScript  DOMNamedNodeMap_object.setNamedItem(DOMNode) 


Right arrow
Next Topic
Left arrow
Previous Topic
Table of contents
Table of Contents

Copyright © SoftQuad Software Inc. 1999