getIntValue (DOMElement - JavaScript)
Gets the integer value of a data element.
Defined in
DOMElementSyntax
getIntValue() : long
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 integer value of the element. |
Usage
This method is equivalent to getIntValue in DOMDocument.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.
This
method works on either:
- The current element if no parameters are specified.
- The first element that matches the XPath.
If the XPath includes namespace prefixes, define the namespaces in the second parameter, first creating a new NamespaceContextImpl object and adding the namespaces with addNamespace.
Examples
(1) This buttononclick event
gets the integer value of the element that is the first child at the
second level of the DOM. The requestScope variables
are bound to edit boxes on the page so the user specifies i before
clicking the button, and gets back y or msg.var dc = database.getAllDocuments();
if(dc.getDocumentCount() > 0) {
if(requestScope.i != null &&
requestScope.i >= 0 &&
requestScope.i < dc.getDocumentCount()) {
var ar = dc.getDocumentArray(requestScope.i + 1);
var doc = ar[i];
var schema = doc.getDocumentElement();
var elem = schema.getFirstChild();
requestScope.y = elem.getIntValue();
} else {
requestScope.msg = "No such document";
}
} else {
requestScope.msg = "No documents in database";
}If the XML of the accessed document is as follows,
the sample code returns
33.0.<schema0>
<element3>33</element3>
</schema0>(2) This button
onclick event
gets the integer value of the first element that matches an XPath.
The requestScope variables are bound to edit boxes
on the page so the user specifies i before clicking
the button, and gets back y or msg.var dc = database.getAllDocuments();
if(dc.getDocumentCount() > 0) {
if(requestScope.i != null &&
requestScope.i >= 0 &&
requestScope.i < dc.getDocumentCount()) {
var ar = dc.getDocumentArray(requestScope.i + 1);
var doc = ar[i];
var elem = doc.getDocumentElement();
requestScope.y = elem.getIntValue("/schema0/element3");
} else {
requestScope.msg = "No such document";
}
} else {
requestScope.msg = "No documents in database";
}(3) This button
onclick event
gets the integer value of the first element that matches an XPath
that uses a namespace. The requestScope variables
are bound to edit boxes on the page so the user specifies i before
clicking the button, and gets back y or msg.var dc = database.getAllDocuments();
if(dc.getDocumentCount() > 0) {
if(requestScope.i != null &&
requestScope.i >= 0 &&
requestScope.i < dc.getDocumentCount()) {
var ns = new NamespaceContextImpl();
ns.addNamespace("p", "http://mynamespace.com");
var ar = dc.getDocumentArray(requestScope.i + 1);
var doc = ar[i];
var elem = doc.getDocumentElement();
requestScope.y = elem.getIntValue("/p:schema0/p:element3", ns);
} else {
requestScope.msg = "No such document";
}
} else {
requestScope.msg = "No documents in database";
}