Problems dereferencing XML object with javascript
Posted: Mon Dec 02, 2013 3:20 pm
This is an addendum to an earlier post.
I am attempting to dereference the following XML object:
using the following Javascript methods:
Referencing the function above with the following:
always returns null. Numerous tests with serveral variants of the function indicates the there are no text nodes in the DOC under the "<workerId>" element tag. Without some mechanism for debugging the XML parsing, I can't really say why the text nodes don't appear. Any help would be much appreciated.
I am attempting to dereference the following XML object:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<IVRAuthenticationContext>
<class>com.spiekerpoint.spider.api.IVRAuthenticationContext</class>
<clientAdministratorId/>
<name>Sam Electrician</name>
<workerId>3</workerId>
</IVRAuthenticationContext>
Code: Select all
function getElementText(document, tag) {
element = document.getElementsByTagName(tag).item(0);
if (element) {
contentNodes = element.childNodes
textNode = contentNodes.firstChild
if (textNode) {
return(textNode.nodeValue)
}
}
}
Referencing the function above with the following:
Code: Select all
<assign name="workerId" expr="getElementText(context,'workerId')" />