I discuss basic pattern matching in Lua in chapter 7 of our book. I'm thinking you'll need to do something like this. Assume that variable "nuance_res" contains the blurb that you posted below. freeswitch.consoleLog("INFO","Result is:\n" .. nuance_res .. "\n") confidence = string.gsub(nuance_res,'.-confidence="(0\.%d%d).+',"%1") freeswitch.consoleLog("NOTICE","Confidence: " .. confidence .. "\n") input = string.gsub(nuance_res,'.-<input mode=".-">(.-)<.+',"%1") freeswitch.consoleLog("NOTICE","Input: " .. input .. "\n") instance = string.gsub(nuance_res,'.-<instance>(.-)<.+',"%1") freeswitch.consoleLog("NOTICE","Instance: " .. instance .. "\n") -MC On Sun, Sep 11, 2011 at 11:26 PM, Glen Ganderton < Glen.Ganderton@premier.com.au> wrote:
Hey Guys,****
** **
I’m currently trying to create a basic IVR with voice recognition (just a simple YES or NO response). I have successfully configured the freeswitch MRCP client to connect to my nuance MRCP server and I successfully get a responses from the server. Now what I need to do is process the response in my freeswitch lua script. The nuance box returns the following:****
** **
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ****
Completion-Cause: 000 success****
Content-Type: application/nlsml+xml****
Content-Length: 178****
** **
<?xml version='1.0'?><result><interpretation grammar="session:nuance5-mrcp2" confidence="0.99"><input mode="speech">yes</input><instance>true</instance></interpretation></result> ****
** **
Now what I want to be able to do is parse the XML in my lua script so that I can simply have the XML stored in some variables:****
** **
Eg.****
** **
Confidence = 0.99****
Input = yes****
Instance = true****
….etc.****
** **
I am just starting to learn lua and am unable to do this myself. I have seen a few scripts online to parse XML for lua but none seem to work correctly (maybe they are meant for different format..not sure).****
** **
If anybody could point me in the right direction or write some sample code for what I need to do that would be a great help.****
** **
Thanks in advance.****
** **
-Glen****
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org