Home | Top | Website design | JavaScript Editor JavaScript EditorGet Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.


selectNodes Method

Applies the specified pattern-matching operation to this node's context and returns the list of matching nodes as IXMLDOMNodeList .

Script Syntax

var objXMLDOMNodeList = oXMLDOMNode.selectNodes( expression );

Parameters

expression A string specifying an XPath expression.

Return Value

An object. Returns the collection of nodes selected by applying the given pattern-matching operation. If no nodes are selected, returns an empty collection.

Example

The following script example creates an IXMLDOMNodeList object containing the nodes specified by the expression parameter (for example, all the <xsl:template> nodes in an XSLT stylesheet). It then displays the number of nodes contained in the node list.

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.4.0");
var objNodeList; xmlDoc.async = false;
xmlDoc.resolveExternals = false;
xmlDoc.load("hello.xsl");
if (xmlDoc.parseError.errorCode <> 0)
{    var myErr = xmlDoc.parseError;  
  alert("You have error " + myErr.reason); }
else {    xmlDoc.setProperty("SelectionNamespaces",       "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'");
   xmlDoc.setProperty("SelectionLanguage", "XPath");
   objNodeList = xmlDoc.documentElement.selectNodes("//xsl:template");
   alert(objNodeList.length); }

 

Home | Top | Website design | JavaScript Editor JavaScript EditorGet Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.