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.<div><br></div>
<div><div><font class="Apple-style-span" face="'courier new', monospace">freeswitch.consoleLog("INFO","Result is:\n" .. nuance_res .. "\n") </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">confidence = string.gsub(nuance_res,'.-confidence="(0\.%d%d).+',"%1") </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">freeswitch.consoleLog("NOTICE","Confidence: " .. confidence .. "\n") </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">input = string.gsub(nuance_res,'.-<input mode=".-">(.-)<.+',"%1") </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">freeswitch.consoleLog("NOTICE","Input: " .. input .. "\n") </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">instance = string.gsub(nuance_res,'.-<instance>(.-)<.+',"%1") </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">freeswitch.consoleLog("NOTICE","Instance: " .. instance .. "\n") </font></div></div><div><br></div><div>-MC</div><div>
<div><br><div class="gmail_quote">On Sun, Sep 11, 2011 at 11:26 PM, Glen Ganderton <span dir="ltr"><<a href="mailto:Glen.Ganderton@premier.com.au">Glen.Ganderton@premier.com.au</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div lang="EN-AU" link="blue" vlink="purple"><div><p class="MsoNormal">Hey Guys,<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">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:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<u></u><u></u></p>
<p class="MsoNormal">Completion-Cause: 000 success<u></u><u></u></p><p class="MsoNormal">Content-Type: application/nlsml+xml<u></u><u></u></p><p class="MsoNormal">Content-Length: 178<u></u><u></u></p><p class="MsoNormal">
<u></u> <u></u></p><div style="border:none;border-bottom:solid windowtext 1.0pt;padding:0cm 0cm 1.0pt 0cm"><p class="MsoNormal" style="border:none;padding:0cm"><?xml version='1.0'?><result><interpretation grammar="session:nuance5-mrcp2" confidence="0.99"><input mode="speech">yes</input><instance>true</instance></interpretation></result><u></u><u></u></p>
</div><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">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:<u></u><u></u></p><p class="MsoNormal">
<u></u> <u></u></p><p class="MsoNormal">Eg.<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Confidence = 0.99<u></u><u></u></p><p class="MsoNormal">Input = yes<u></u><u></u></p><p class="MsoNormal">
Instance = true<u></u><u></u></p><p class="MsoNormal">….etc.<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">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).<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">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.<u></u><u></u></p><p class="MsoNormal">
<u></u> <u></u></p><p class="MsoNormal">Thanks in advance.<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><font color="#888888"><p class="MsoNormal">-Glen<u></u><u></u></p></font></div></div><br><br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br></div></div>