setSelectionNamespaces (DOMDocument - JavaScript)

Sets namespaces for use in XPath specifications.

Defined in

DOMDocument

Syntax

setSelectionNamespaces(selectionNS:NamespaceContext) : void

Parameters Description
selectionNS A namespace context.

Usage

See DOMNamespaceContextImpl and addNamespace for creating namespaces.

This method sets namespaces for following methods with XPath specifications containing namespace prefixes.

Examples

This example is for the onclick event of a button. It creates a document and sets a value. The requestScope variable is bound to an edit box on the page so the user specifies s before clicking the button.
var doc = database.createNewDocument();
var dom = doc.getDOM();
var ns = new NamespaceContextImpl();
ns.addNamespace("s", "http://mynamespace.com");
dom.setSelectionNamespaces(ns);
dom.setStringValue("/s:schema1/s:element0", requestScope.s);
doc.save()
If the value of requestScope.s is foo, the XML for of the document is as follows:
<s:schema1 xmlns:s="http://mynamespace.com">
  <s:element0>foo</s:element0>
</s:schema1>