I discuss basic pattern matching in Lua in chapter 7 of our book. I&#39;m thinking you&#39;ll need to do something like this. Assume that variable &quot;nuance_res&quot; contains the blurb that you posted below.<div><br></div>
<div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">freeswitch.consoleLog(&quot;INFO&quot;,&quot;Result is:\n&quot; .. nuance_res .. &quot;\n&quot;)                                                                                           </font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">                                                                                                                                                                </font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">confidence = string.gsub(nuance_res,&#39;.-confidence=&quot;(0\.%d%d).+&#39;,&quot;%1&quot;)                                                                                           </font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">freeswitch.consoleLog(&quot;NOTICE&quot;,&quot;Confidence: &quot; .. confidence .. &quot;\n&quot;)                                                                                            </font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">                                                                                                                                                                </font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">input = string.gsub(nuance_res,&#39;.-&lt;input mode=&quot;.-&quot;&gt;(.-)&lt;.+&#39;,&quot;%1&quot;)                                                                                               </font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">freeswitch.consoleLog(&quot;NOTICE&quot;,&quot;Input: &quot; .. input .. &quot;\n&quot;)                                                                                                      </font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">                                                                                                                                                                </font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">instance = string.gsub(nuance_res,&#39;.-&lt;instance&gt;(.-)&lt;.+&#39;,&quot;%1&quot;)                                                                                                   </font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">freeswitch.consoleLog(&quot;NOTICE&quot;,&quot;Instance: &quot; .. instance .. &quot;\n&quot;) </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">&lt;<a href="mailto:Glen.Ganderton@premier.com.au">Glen.Ganderton@premier.com.au</a>&gt;</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">&lt;?xml version=&#39;1.0&#39;?&gt;&lt;result&gt;&lt;interpretation grammar=&quot;session:nuance5-mrcp2&quot; confidence=&quot;0.99&quot;&gt;&lt;input mode=&quot;speech&quot;&gt;yes&lt;/input&gt;&lt;instance&gt;true&lt;/instance&gt;&lt;/interpretation&gt;&lt;/result&gt;<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>