We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics

Node list working, but what about terminal values?

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
moshe
Posts: 66
Joined: Wed Aug 15, 2007 5:36 pm
Location: Chicago
Contact:

Node list working, but what about terminal values?

Post 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?

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

sample XML file needed to reproduce IVR issue

Post by support »

Hi,

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

Regards,
Plum Support
Last edited by support on Tue Dec 29, 2009 12:41 pm, edited 1 time in total.

moshe
Posts: 66
Joined: Wed Aug 15, 2007 5:36 pm
Location: Chicago
Contact:

Post 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>

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

IVR code example for implementing <data> tag

Post 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

Post Reply