getStringValues (DOMDocument - JavaScript)

Gets the string values of the data elements that match an XPath.

Defined in

DOMDocument

Syntax

getStringValues(xpath:string) : string[]

getStringValues(xpath:string, selectionNS:NamespaceContext) : string[]

Parameters Description
xpath The XPath of elements associated with the document.
selectionNS A namespace context.
Return value Description
string[] The data values of the elements.

Usage

This method is equivalent to getStringValue in DOMElement.

In a schema, these data elements should be defined as string. In the data properties, the display type of a bound field should be String.

If the XPath includes namespace prefixes, either:

Examples

(1) This example is for the onclick event of a button. It gets elements from the document specified by an index. The requestScope variables are bound to edit boxes on the page so the user specifies i before clicking the button, and gets back s or msg.
var dc = database.getAllDocuments();
if(dc.getDocumentCount() > 0) {
	if(requestScope.i >= 0 && requestScope.i < dc.getDocumentCount()) {
		var ar = dc.getDocumentArray(requestScope.i + 1);
		var doc = ar[i];
		var dom = doc.getDOM();
		var s = dom.getStringValues("//element0");
		requestScope.s = s.join(", ");
	} else {
		requestScope.msg = "No such document";
	}
} else {
	requestScope.msg = "No documents in database";
}
(2) This example is for the onclick event of a button. It gets elements from the document specified by an index using namespaces. The requestScope variables are bound to edit boxes on the page so the user specifies i before clicking the button, and gets back s or msg.
var dc = database.getAllDocuments();
if(dc.getDocumentCount() > 0) {
	if(requestScope.i >= 0 && requestScope.i < dc.getDocumentCount()) {
		var ar = dc.getDocumentArray(requestScope.i + 1);
		var doc = ar[i];
		var dom = doc.getDOM();
		var ns = new NamespaceContextImpl();
		ns.addNamespace("s", "http://mynamespace.com");
		var s = dom.getStringValues("//s:element0", ns);
		requestScope.s = s.join(", ");
	} else {
		requestScope.msg = "No such document";
	}
} else {
	requestScope.msg = "No documents in database";
}