Page 1 of 1

Node list working, but what about terminal values?

Posted: Tue Sep 25, 2007 5:42 pm
by moshe
I have some code that works to parse messages. First I look into the data retrieved by the data element to get the individual updates:

Code: Select all

updateMessages = messageInfo.documentElement.getElementsByTagName("message")
Next, I look into the updateMessages to find indvidual subelements of message:

Code: Select all

updateMessages.item(i).getElementsByTagName("recent").item(0).textContent
to get the text in the "recent" element inside the i-th message element. (I retreive some other elements as well, edited out for clarity.)

However, this code fails to work on the plumVoice platform. I've tried pulling out individual elements to at least see the nodeType but can't even manage that:


Code: Select all

			<script>
			<![CDATA[
				// another debug hunt
				debugThat = new Array()
				for (var i=0 ; i < updateMessages.length; i++ ) {
					
					debugThat[i] = new Object()
					debugThat[i].recent = updateMessages.item(i).getElementsByTagName("recent").item(0)
				}					
				
			]]>
			</script>
			<!-- DEBUG printouts -->
			<log expr="logdelim + 'elements first child, entries ' + debugThat.length"/>
			<foreach array="debugThat" item="index">
				<log expr="logdelim + 'item type:' 				+ index.nodeType" />
				<log expr="logdelim + 'item recent: ' 			+ index.recent"/>
				
			</foreach>					
I realize that the very last log statement probably won't print anything sensible. However, the first on ought to. Is getElementByTag() failing to work on a node taken from a nodeList, even though the node is an element?

sample XML file needed to reproduce IVR issue

Posted: Wed Sep 26, 2007 9:47 am
by support
Hi,

Could you provide us with a sample XML file to help us reproduce this IVR problem?

Regards,
Plum Support

Posted: Wed Sep 26, 2007 11:05 am
by moshe
After one *heck* of a lot of experimentation, I was able to get this to work.

Apparently, I need to use

Code: Select all

item(0).firstChild.toString()
and as far as I can tell,

Code: Select all

item(0).firstChild.data
doesn't work -- if I'm recalling all the steps correctly. I find it peculiar that .data doesn't work, as it's supposed to give a String.

There's also is an error on my part. VoiceXML 2.1, Appendix D, doesn't support textContent as a property of the Node object, and as such I shouldn't have expected it to work.

If you could answer whether or not .data is supposed to work I'd appreciate it.

The data I was using was, in part:

Code: Select all

<retInfo>
	<message>
		<recent>good morning</recent>
	</message>
	<message>
		<recent>good afternoon</recent>
	</message>
</retInfo>

IVR code example for implementing <data> tag

Posted: Wed Sep 26, 2007 12:42 pm
by support
Hi,

The way we implement the <data> tag is to use ".toString()", which can be shown in our IVR example here:

http://www.plumvoice.com/docs/dev/voice ... tamaxstale

Since the documentation on VoiceXML 2.1 is not finalized yet, we have not implemented the <data> tag to use ".data", but it is being considered for the next IVR platform release.

Regards,
Plum Support