getIntValue (DOMDocument - JavaScript)
Gets the integer value of the first data element that matches an XPath.
Defined in
DOMDocumentSyntax
getIntValue(xpath:string) : long
getIntValue(xpath:string, selectionNS:NamespaceContext)
: long
Parameters | Description |
---|---|
xpath |
The XPath of an element associated with the document. |
selectionNS |
A namespace context. |
Return value | Description |
---|---|
long |
The value of the data element. |
Usage
This method is equivalent to getIntValue in DOMElement.In a schema,
this data element should be defined as integer
. In
the data properties, the display type of a bound field should be Number
.
If
the XPath includes namespace prefixes, either:
- Define the namespaces in the second parameter, first creating a new DOMNamespaceContextImpl object and adding the namespaces with addNamespace.
- Define the namespaces with setSelectionNamespaces before using this method without the second parameter.
Examples
(1) This example is for theonclick
event
of a button. It gets an element 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 m
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();
requestScope.m = dom.getIntValue("/schema1/element3");
} else {
requestScope.msg = "No such document";
}
} else {
requestScope.msg = "No documents in database";
}
(2) This example is for the
onclick
event
of a button using namespaces. It gets an element 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 m
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");
requestScope.m = dom.getIntValue("/s:schema1/s:element3", ns);
} else {
requestScope.msg = "No such document";
}
} else {
requestScope.msg = "No documents in database";
}