📄 使用perl创建voicexml应用程序 - fanqiang_com.htm
字号:
<TD class=a14>if ($response->is_success)
{</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>eval {</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>$xp = XML::XPath->new(xml =>
$response->content);</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>$xp->find('/');</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>};</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>$error = 'Error parsing RSS file ' . $@ if
$@;</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>}</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>else {</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>$error = 'Remote server returned ' .
$response->message();</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>}</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD
class=a14>如果出现错误,脚本则会向用户返回一个描述错误的audio消息,挂断当前用户的连接,并关闭脚本。</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>if ( defined($error) )
{</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>print qq*</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14><BLOCK><SPAN lang=EN-US><SPAN
style="mso-spacerun: yes"> </SPAN><form
id="headlines"></SPAN></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14><AUDIO><SPAN lang=EN-US><SPAN
style="mso-spacerun: yes">
</SPAN><block></SPAN></TD></TR>
<TR>
<TD class=a14><SPAN lang=EN-US><SPAN
style="mso-spacerun: yes">
</SPAN><audio></SPAN></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>I'm sorry. The following error occurred
while fetching</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>the headlines file. $error Please try
again later.</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14></AUDIO><SPAN lang=EN-US><SPAN
style="mso-spacerun: yes">
</SPAN></audio></SPAN></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14><DISCONNECT /><SPAN lang=EN-US><SPAN
style="mso-spacerun: yes">
</SPAN><disconnect/></SPAN></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14></BLOCK><SPAN lang=EN-US><SPAN
style="mso-spacerun: yes">
</SPAN></block></SPAN></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14></FORM><SPAN lang=EN-US><SPAN
style="mso-spacerun: yes">
</SPAN></form></SPAN></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14></VXML><SPAN
lang=EN-US></vxml></SPAN></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>*;</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>}</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD
class=a14>如果RSS文件的获取和解析过程都没有出现错误,我们将创建一个新的form元素,然后,利用封装在block中的一个audio元素,通知用户解析已经成功,准备收听他所需要的信息。</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>else {</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>print qq*</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14><SPAN lang=EN-US><SPAN
style="mso-spacerun: yes"> </SPAN><form
id="headlines"></SPAN><BLOCK></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14><AUDIO><SPAN lang=EN-US><SPAN
style="mso-spacerun: yes">
</SPAN><block></SPAN></TD></TR>
<TR>
<TD class=a14><SPAN lang=EN-US><SPAN
style="mso-spacerun: yes">
</SPAN><audio></SPAN></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>The RSS file has been fetched and
processed successfully. The</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>following modules have recently been up
loaded to c pan.</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14></AUDIO><SPAN lang=EN-US><SPAN
style="mso-spacerun: yes">
</SPAN></audio></SPAN></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14></BLOCK><SPAN lang=EN-US><SPAN
style="mso-spacerun: yes">
</SPAN></block></SPAN></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14><BLOCK><SPAN lang=EN-US><SPAN
style="mso-spacerun: yes">
</SPAN><block></SPAN></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>*;</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD
class=a14>然后,我们在一个循环中处理RSS文档中的所有item元素。对于每一个item元素我们都输出一个相应的audio元素,让VoiceXML文档使用每个item元素title子元素的值作为需要输出的文本内容。</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>foreach my $news_item
($xp->findnodes('//item')) {</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>print "<AUDIO><SPAN lang=EN-US
style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><audio></SPAN>"
.</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>$news_item->findvalue('title')
.</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>"</AUDIO>\n";</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>}</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD
class=a14>最后我们告知用户整个名单已经读完了,并欢迎他明天继续拨打,然后断开连接并关闭VoiceXML文档。</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>print qq*</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14><AUDIO><SPAN lang=EN-US><SPAN
style="mso-spacerun: yes">
</SPAN><audio></SPAN></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>This completes the latest c pan up loads.
Please call again tomorrow.</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14></AUDIO><SPAN lang=EN-US><SPAN
style="mso-spacerun: yes">
</SPAN></audio></SPAN></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14><DISCONNECT /><SPAN lang=EN-US><SPAN
style="mso-spacerun: yes">
</SPAN><disconnect/></SPAN></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14></BLOCK><SPAN lang=EN-US><SPAN
style="mso-spacerun: yes">
</SPAN></block></SPAN></TD></TR></TBODY></TABLE>
<TABLE width="100%">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -