zl程序教程

您现在的位置是:首页 >  后端

当前栏目

一个XML解析实例

实例XML 一个 解析
2023-09-11 14:19:39 时间

xml内容:

"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n                                    <aiml>\n                                    <category><pattern>*充*到*</pattern><template>尊敬的用户,请点击下面链接提交充值问题的相关信息,我们会尽快为您确认。</template><url2 id=\"510822\" type=\"9\" title=\"wuchao_3填写充值不到账表单2\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=def41fccd52c473e969b6631a76d2af7\"></url2> <tag name=\"2342342342\" id=\"106203\"/><tag name=\"421412\" id=\"119491\"/></category><category><pattern>*买*到*</pattern><template>尊敬的用户,请点击下面链接提交充值问题的相关信息,我们会尽快为您确认。</template><url2 id=\"510822\" type=\"9\" title=\"wuchao_3填写充值不到账表单2\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=def41fccd52c473e969b6631a76d2af7\"></url2> <tag name=\"2342342342\" id=\"106203\"/><tag name=\"421412\" id=\"119491\"/></category><category><pattern>*充值*</pattern><template>尊敬的用户,请点击下面链接提交充值问题的相关信息,我们会尽快为您确认。</template><url2 id=\"510822\" type=\"9\" title=\"wuchao_3填写充值不到账表单2\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=def41fccd52c473e969b6631a76d2af7\"></url2> <tag name=\"2342342342\" id=\"106203\"/><tag name=\"421412\" id=\"119491\"/></category><category><pattern>公告</pattern><action name=\"xxx活动上线啦\" reply=\"xxx活动上线啦\"></action><template>点击下列选项,了解最新动态</template><url2 id=\"510825\" type=\"9\" title=\"测试\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=f172e99a0d934aa1bdb8ea26aa605660\"></url2> <tag name=\"wuchao\" id=\"106259\"/></category><category><pattern>网络诊断</pattern><action name=\"ping\" reply=\"ping\"></action><action name=\"traceroute\" reply=\"traceroute\"></action><template>这是网络诊断</template><url2 id=\"510826\" type=\"9\" title=\"Form_big标签\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=ff71184078964b7ebb2d86407d9a055c\"></url2> </category><category><pattern>随机测试</pattern><url title=\"本站链接\" content=\"https://bilibili.com\" ></url> <action name=\"明天\" reply=\"明天\"></action><action name=\"最近\" reply=\"最近\"></action><template>这是随机测试表单</template><url2 id=\"510827\" type=\"9\" title=\"测试版\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=ca8c9e23459842abb81d0de23d95ad3c\"></url2> <tag name=\"account is frozen\" id=\"119181\"/></category><category><pattern>日常测试表单</pattern><template>这是最简单的表单</template><url2 id=\"510828\" type=\"9\" title=\"提交建议(日志上传)\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=b77a3aa10cd74c4788e6095fb203a7cd\"></url2> </category><category><pattern>TRACEROUTE</pattern><template>这是traceroute方式</template><tag name=\"账号冻结\" id=\"119712\"/></category><category><pattern>反馈BUG</pattern><action name=\"活动bug\" reply=\"活动bug\"></action><action name=\"其他bug\" reply=\"其他bug\"></action><template>尊敬的客户,请选择您要反馈的bug类型:</template><url2 id=\"510834\" type=\"9\" title=\"Form_充值异常\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=ea6240c4bc364d7881500f8d08b72dcb\"></url2> </category><category><pattern>账号被盗</pattern><template>尊敬的用户,请您点击下面链接提交账号被盗表单,我们会尽快为您找回。更新</template><url2 id=\"510835\" type=\"9\" title=\"Form_举报非法玩家\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=d8ae1c8a37b74c0a9389adea34645e88\"></url2> </category><category><pattern>外链传参数</pattern><template>测试</template><url2 id=\"510838\" type=\"9\" title=\"百度一下你就知道\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://www.baidu.com/\"></url2> <tag name=\"cheating\" id=\"63473\"/></category><category><pattern>PING</pattern><template>这是ping方式</template><tag name=\"账号\" id=\"80942\"/></category><category><pattern>账号被冻结</pattern><template>尊敬的玩家,请您点击下面链接提交账号被冻结表单,我们会尽快确认并给您答复。</template><url2 id=\"510844\" type=\"9\" title=\"Form_(Copy)账号冻结\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" ></url2> <tag name=\"account is frozen\" id=\"119181\"/></category><category><pattern>图片</pattern><template>图片上传填写表单</template><url2 id=\"510846\" type=\"9\" title=\"上传图片\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=9dc4269be3464a4eb32eaeb7d5df329e\"></url2> </category><category><pattern>*建议*</pattern><url title=\"点击此处填写意见表单\" content=\"https://aihelp.net/Elva/Forms/Fill.aspx?id=0819d585d5e04b05ba348ec451fdd863\" ></url> <template>尊敬的用户,欢迎您提出自己的宝贵意见,也可以吐槽您的不满,我们会用心倾听每个用户的声音,并在后续的版本中体现。1</template><url2 id=\"510848\" type=\"9\" title=\"人工客服测试\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=2396f25dcc5a49e1bfed85864a8c4fec\"></url2> </category><category><pattern>*意见*</pattern><url title=\"点击此处填写意见表单\" content=\"https://aihelp.net/Elva/Forms/Fill.aspx?id=0819d585d5e04b05ba348ec451fdd863\" ></url> <template>尊敬的用户,欢迎您提出自己的宝贵意见,也可以吐槽您的不满,我们会用心倾听每个用户的声音,并在后续的版本中体现。1</template><url2 id=\"510848\" type=\"9\" title=\"人工客服测试\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=2396f25dcc5a49e1bfed85864a8c4fec\"></url2> </category><category><pattern>*</pattern><template>抱歉,请提交人工客诉</template><url2 id=\"510849\" type=\"9\" title=\"人工客服测试\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=2396f25dcc5a49e1bfed85864a8c4fec\"></url2> <alicekm id=\"510849\" type=\"wildcard\" ></alicekm> </category><category><pattern>测试场景</pattern><action name=\"特殊字符\" reply=\"特殊字符\"></action><action name=\"测试图片和视频\" reply=\"测试图片和视频\"></action><action name=\"外链传参数\" reply=\"外链传参数\"></action><action name=\"带自定义URL\" reply=\"带自定义URL\"></action><action name=\"带日期\" reply=\"带日期\"></action><action name=\"日常测试表单\" reply=\"日常测试表单\"></action><action name=\"随机测试\" reply=\"随机测试\"></action><template>这是测试要用的常用操作,请不要删除id=(测试专用)id=</template><url2 id=\"510850\" type=\"9\" title=\"Form_人工客服\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=f97ef8b4957d4fb99aa3cc8dc88d59c4\"></url2> </category><category><pattern>账号丢失</pattern><template>尊敬的用户,请您点击下面链接提交账号丢失表单,我们会尽快为您核实并找回。</template><url2 id=\"510851\" type=\"9\" title=\"Form_测试创建中文\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" ></url2> </category><category><pattern>视频</pattern><action name=\"啊大大\" reply=\"啊大大\"></action><template>阿达阿萨德</template><url2 id=\"510854\" type=\"9\" title=\"Form_测试场传视频\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=d0ef146c356e4cbcb4421e8e63039502\"></url2> <tag name=\"accountisfrozen\" id=\"119179\"/></category><category><pattern>账号问题</pattern><action name=\"账号丢失\" reply=\"账号丢失\"></action><action name=\"账号被冻结\" reply=\"账号被冻结\"></action><action name=\"账号被盗\" reply=\"账号被盗\"></action><template>尊敬的用户,请问选择下列您遇到的账号问题:</template><url2 id=\"510855\" type=\"9\" title=\"Form_提交游戏建议\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=e181091f096b4af5bb11adb08c34a788\"></url2> <tag name=\"account is frozen\" id=\"119181\"/></category><category><pattern>DEFAULTWELCOMETEXT</pattern><action name=\"公告\" reply=\"公告\"></action><action name=\"账号问题\" reply=\"账号问题\"></action><action name=\"充值不到账\" reply=\"充值不到账\"></action><action name=\"反馈Bug\" reply=\"反馈Bug\"></action><action name=\"我要提建议\" reply=\"我要提建议\"></action><action name=\"网络诊断\" reply=\"网络诊断\"></action><action name=\"投诉举报\" reply=\"投诉举报\"></action><action name=\"测试场景\" reply=\"测试场景\"></action><template>尊敬的用户,我是您的智能小客服Elva(艾娃),欢迎来到Tryaihelp本地环境。\n您可以在屏幕底部直接输入您的问题,也可以选择下列服务类型提交表单给人工客服,或者点击右上角直接联系人工客服。112</template><url2 id=\"510856\" type=\"9\" title=\"自耦电脑\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=f97ef8b4957d4fb99aa3cc8dc88d59c4\"></url2> <tag name=\"345sdgfdsdf\" id=\"106204\"/><tag name=\"421412\" id=\"119491\"/></category><category><pattern>活动BUG</pattern><template>请您点击下方链接,详细填写bug表单,我们会尽快核实并解决您问题。</template><url2 id=\"510859\" type=\"9\" title=\"提交活动bug表单\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=308e2a7ab16a4842a7edb800fc3cb97c\"></url2> </category><category><pattern>测试图片和视频</pattern><url title=\"please tap here to provid:e us with more information\" content=\"https://www.baidu.com\" ></url> <action name=\"图片\" reply=\"图片\"></action><action name=\"视频\" reply=\"视频\"></action><action name=\"百度\" reply=\"百度\"></action><template>请填写表单(带自定义url)id=</template><url2 id=\"510860\" type=\"9\" title=\"Form_测试 专用\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=f1bb03c6846b4ea08173c24b144d4352\"></url2> <tag name=\"模拟器测试\" id=\"60080\"/><tag name=\"账号\" id=\"80942\"/></category><category><pattern>其他BUG</pattern><template>请您点击下方链接,详细填写bug表单,我们会尽快核实并解决您问题。</template><url2 id=\"510867\" type=\"9\" title=\"其他bug提交\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" ></url2> <tag name=\"other bug\" id=\"63474\"/></category><category><pattern>测试场景</pattern><that>尊敬的用户 我是您的智能小客服ELVA 艾娃 欢迎来到TRYAIHELP本地环境 您可以在屏幕底部直接输入您的问题 也可以选择下列服务类型提交表单给人工客服 或者点击右上角直接联系人工客服 112</that><action name=\"特殊字符\" reply=\"特殊字符\"></action><action name=\"测试图片和视频\" reply=\"测试图片和视频\"></action><action name=\"外链传参数\" reply=\"外链传参数\"></action><action name=\"带自定义URL\" reply=\"带自定义URL\"></action><action name=\"带日期\" reply=\"带日期\"></action><action name=\"日常测试表单\" reply=\"日常测试表单\"></action><action name=\"随机测试\" reply=\"随机测试\"></action><template>这是测试要用的常用操作,请不要删除id=(测试专用)id=</template><url2 id=\"510850\" type=\"9\" title=\"Form_人工客服\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=f97ef8b4957d4fb99aa3cc8dc88d59c4\"></url2> </category><category><pattern>外链传参数</pattern><that>这是测试要用的常用操作 请不要删除ID 测试专用 ID </that><template>测试</template><url2 id=\"510838\" type=\"9\" title=\"百度一下你就知道\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://www.baidu.com/\"></url2> <tag name=\"cheating\" id=\"63473\"/></category><category><pattern>测试图片和视频</pattern><that>这是测试要用的常用操作 请不要删除ID 测试专用 ID </that><url title=\"please tap here to provid:e us with more information\" content=\"https://www.baidu.com\" ></url> <action name=\"图片\" reply=\"图片\"></action><action name=\"视频\" reply=\"视频\"></action><action name=\"百度\" reply=\"百度\"></action><template>请填写表单(带自定义url)id=</template><url2 id=\"510860\" type=\"9\" title=\"Form_测试 专用\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=f1bb03c6846b4ea08173c24b144d4352\"></url2> <tag name=\"模拟器测试\" id=\"60080\"/><tag name=\"账号\" id=\"80942\"/></category><category><pattern>视频</pattern><that>请填写表单 带自定义URL ID </that><action name=\"啊大大\" reply=\"啊大大\"></action><template>阿达阿萨德</template><url2 id=\"510854\" type=\"9\" title=\"Form_测试场传视频\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=d0ef146c356e4cbcb4421e8e63039502\"></url2> <tag name=\"accountisfrozen\" id=\"119179\"/></category><category><pattern>图片</pattern><that>请填写表单 带自定义URL ID </that><template>图片上传填写表单</template><url2 id=\"510846\" type=\"9\" title=\"上传图片\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=9dc4269be3464a4eb32eaeb7d5df329e\"></url2> </category><category><pattern>日常测试表单</pattern><that>这是测试要用的常用操作 请不要删除ID 测试专用 ID </that><template>这是最简单的表单</template><url2 id=\"510828\" type=\"9\" title=\"提交建议(日志上传)\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=b77a3aa10cd74c4788e6095fb203a7cd\"></url2> </category><category><pattern>公告</pattern><that>尊敬的用户 我是您的智能小客服ELVA 艾娃 欢迎来到TRYAIHELP本地环境 您可以在屏幕底部直接输入您的问题 也可以选择下列服务类型提交表单给人工客服 或者点击右上角直接联系人工客服 112</that><action name=\"xxx活动上线啦\" reply=\"xxx活动上线啦\"></action><template>点击下列选项,了解最新动态</template><url2 id=\"510825\" type=\"9\" title=\"测试\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=f172e99a0d934aa1bdb8ea26aa605660\"></url2> <tag name=\"wuchao\" id=\"106259\"/></category><category><pattern>账号问题</pattern><that>尊敬的用户 我是您的智能小客服ELVA 艾娃 欢迎来到TRYAIHELP本地环境 您可以在屏幕底部直接输入您的问题 也可以选择下列服务类型提交表单给人工客服 或者点击右上角直接联系人工客服 112</that><action name=\"账号丢失\" reply=\"账号丢失\"></action><action name=\"账号被冻结\" reply=\"账号被冻结\"></action><action name=\"账号被盗\" reply=\"账号被盗\"></action><template>尊敬的用户,请问选择下列您遇到的账号问题:</template><url2 id=\"510855\" type=\"9\" title=\"Form_提交游戏建议\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=e181091f096b4af5bb11adb08c34a788\"></url2> <tag name=\"account is frozen\" id=\"119181\"/></category><category><pattern>账号丢失</pattern><that>尊敬的用户 请问选择下列您遇到的账号问题 </that><template>尊敬的用户,请您点击下面链接提交账号丢失表单,我们会尽快为您核实并找回。</template><url2 id=\"510851\" type=\"9\" title=\"Form_测试创建中文\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" ></url2> </category><category><pattern>账号被冻结</pattern><that>尊敬的用户 请问选择下列您遇到的账号问题 </that><template>尊敬的玩家,请您点击下面链接提交账号被冻结表单,我们会尽快确认并给您答复。</template><url2 id=\"510844\" type=\"9\" title=\"Form_(Copy)账号冻结\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" ></url2> <tag name=\"account is frozen\" id=\"119181\"/></category><category><pattern>账号被盗</pattern><that>尊敬的用户 请问选择下列您遇到的账号问题 </that><template>尊敬的用户,请您点击下面链接提交账号被盗表单,我们会尽快为您找回。更新</template><url2 id=\"510835\" type=\"9\" title=\"Form_举报非法玩家\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=d8ae1c8a37b74c0a9389adea34645e88\"></url2> </category><category><pattern>*充*到*</pattern><that>尊敬的用户 我是您的智能小客服ELVA 艾娃 欢迎来到TRYAIHELP本地环境 您可以在屏幕底部直接输入您的问题 也可以选择下列服务类型提交表单给人工客服 或者点击右上角直接联系人工客服 112</that><template>尊敬的用户,请点击下面链接提交充值问题的相关信息,我们会尽快为您确认。</template><url2 id=\"510822\" type=\"9\" title=\"wuchao_3填写充值不到账表单2\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=def41fccd52c473e969b6631a76d2af7\"></url2> <tag name=\"2342342342\" id=\"106203\"/><tag name=\"421412\" id=\"119491\"/></category><category><pattern>*买*到*</pattern><that>尊敬的用户 我是您的智能小客服ELVA 艾娃 欢迎来到TRYAIHELP本地环境 您可以在屏幕底部直接输入您的问题 也可以选择下列服务类型提交表单给人工客服 或者点击右上角直接联系人工客服 112</that><template>尊敬的用户,请点击下面链接提交充值问题的相关信息,我们会尽快为您确认。</template><url2 id=\"510822\" type=\"9\" title=\"wuchao_3填写充值不到账表单2\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=def41fccd52c473e969b6631a76d2af7\"></url2> <tag name=\"2342342342\" id=\"106203\"/><tag name=\"421412\" id=\"119491\"/></category><category><pattern>*充值*</pattern><that>尊敬的用户 我是您的智能小客服ELVA 艾娃 欢迎来到TRYAIHELP本地环境 您可以在屏幕底部直接输入您的问题 也可以选择下列服务类型提交表单给人工客服 或者点击右上角直接联系人工客服 112</that><template>尊敬的用户,请点击下面链接提交充值问题的相关信息,我们会尽快为您确认。</template><url2 id=\"510822\" type=\"9\" title=\"wuchao_3填写充值不到账表单2\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=def41fccd52c473e969b6631a76d2af7\"></url2> <tag name=\"2342342342\" id=\"106203\"/><tag name=\"421412\" id=\"119491\"/></category><category><pattern>反馈BUG</pattern><that>尊敬的用户 我是您的智能小客服ELVA 艾娃 欢迎来到TRYAIHELP本地环境 您可以在屏幕底部直接输入您的问题 也可以选择下列服务类型提交表单给人工客服 或者点击右上角直接联系人工客服 112</that><action name=\"活动bug\" reply=\"活动bug\"></action><action name=\"其他bug\" reply=\"其他bug\"></action><template>尊敬的客户,请选择您要反馈的bug类型:</template><url2 id=\"510834\" type=\"9\" title=\"Form_充值异常\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=ea6240c4bc364d7881500f8d08b72dcb\"></url2> </category><category><pattern>活动BUG</pattern><that>尊敬的客户 请选择您要反馈的BUG类型 </that><template>请您点击下方链接,详细填写bug表单,我们会尽快核实并解决您问题。</template><url2 id=\"510859\" type=\"9\" title=\"提交活动bug表单\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=308e2a7ab16a4842a7edb800fc3cb97c\"></url2> </category><category><pattern>其他BUG</pattern><that>尊敬的客户 请选择您要反馈的BUG类型 </that><template>请您点击下方链接,详细填写bug表单,我们会尽快核实并解决您问题。</template><url2 id=\"510867\" type=\"9\" title=\"其他bug提交\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" ></url2> <tag name=\"other bug\" id=\"63474\"/></category><category><pattern>*建议*</pattern><that>尊敬的用户 我是您的智能小客服ELVA 艾娃 欢迎来到TRYAIHELP本地环境 您可以在屏幕底部直接输入您的问题 也可以选择下列服务类型提交表单给人工客服 或者点击右上角直接联系人工客服 112</that><url title=\"点击此处填写意见表单\" content=\"https://aihelp.net/Elva/Forms/Fill.aspx?id=0819d585d5e04b05ba348ec451fdd863\" ></url> <template>尊敬的用户,欢迎您提出自己的宝贵意见,也可以吐槽您的不满,我们会用心倾听每个用户的声音,并在后续的版本中体现。1</template><url2 id=\"510848\" type=\"9\" title=\"人工客服测试\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=2396f25dcc5a49e1bfed85864a8c4fec\"></url2> </category><category><pattern>*意见*</pattern><that>尊敬的用户 我是您的智能小客服ELVA 艾娃 欢迎来到TRYAIHELP本地环境 您可以在屏幕底部直接输入您的问题 也可以选择下列服务类型提交表单给人工客服 或者点击右上角直接联系人工客服 112</that><url title=\"点击此处填写意见表单\" content=\"https://aihelp.net/Elva/Forms/Fill.aspx?id=0819d585d5e04b05ba348ec451fdd863\" ></url> <template>尊敬的用户,欢迎您提出自己的宝贵意见,也可以吐槽您的不满,我们会用心倾听每个用户的声音,并在后续的版本中体现。1</template><url2 id=\"510848\" type=\"9\" title=\"人工客服测试\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=2396f25dcc5a49e1bfed85864a8c4fec\"></url2> </category><category><pattern>*</pattern><that>尊敬的用户 我是您的智能小客服ELVA 艾娃 欢迎来到TRYAIHELP本地环境 您可以在屏幕底部直接输入您的问题 也可以选择下列服务类型提交表单给人工客服 或者点击右上角直接联系人工客服 112</that><template>抱歉,请提交人工客诉</template><url2 id=\"510849\" type=\"9\" title=\"人工客服测试\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=2396f25dcc5a49e1bfed85864a8c4fec\"></url2> <alicekm id=\"510849\" type=\"wildcard\" ></alicekm> </category><category><pattern>网络诊断</pattern><that>尊敬的用户 我是您的智能小客服ELVA 艾娃 欢迎来到TRYAIHELP本地环境 您可以在屏幕底部直接输入您的问题 也可以选择下列服务类型提交表单给人工客服 或者点击右上角直接联系人工客服 112</that><action name=\"ping\" reply=\"ping\"></action><action name=\"traceroute\" reply=\"traceroute\"></action><template>这是网络诊断</template><url2 id=\"510826\" type=\"9\" title=\"Form_big标签\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=ff71184078964b7ebb2d86407d9a055c\"></url2> </category><category><pattern>PING</pattern><that>这是网络诊断</that><template>这是ping方式</template><tag name=\"账号\" id=\"80942\"/></category><category><pattern>TRACEROUTE</pattern><that>这是网络诊断</that><template>这是traceroute方式</template><tag name=\"账号冻结\" id=\"119712\"/></category><category><pattern>随机测试</pattern><that>尊敬的用户 我是您的智能小客服ELVA 艾娃 欢迎来到TRYAIHELP本地环境 您可以在屏幕底部直接输入您的问题 也可以选择下列服务类型提交表单给人工客服 或者点击右上角直接联系人工客服 112</that><url title=\"本站链接\" content=\"https://bilibili.com\" ></url> <action name=\"明天\" reply=\"明天\"></action><action name=\"最近\" reply=\"最近\"></action><template>这是随机测试表单</template><url2 id=\"510827\" type=\"9\" title=\"测试版\" content=\"https://local.aihelp.net/elva/api/redirect\" varlist=\"\" formurl=\"https://local.aihelp.net/questionnaire/#/?formId=ca8c9e23459842abb81d0de23d95ad3c\"></url2> <tag name=\"account is frozen\" id=\"119181\"/></category>\n                                    </aiml>"

 

上面的xml字符串就是 aimlstory

解析方法:

getStoryJson(){
      let regcategory=/<category.+?<\/category>/gi,
          pattern=/<pattern.+?<\/pattern>/gi,
          template=/<template.+?<\/template>/gi,
          that=/<that.+?<\/that>/gi,
          alicekm=/<alicekm.*?(?:>|\/>)/gi,
          action =/<action.*?(?:>|\/>)/gi,
          url2 =/<url2\s.*?(?:>|\/>)/gi,
          url=/<url\s.*?(?:>|\/>)/gi,
          tag=/<tag.*?(?:>|\/>)/gi,
          getKey=/\s.*?=\"/g,
          getValue=/=\".*?\"(\s|\/>|\>)/g;
      let categoryArr=this.aimlstory.replace(/\r\n|\r|\n/g,'</br>').match(regcategory),botArr=[]
      // console.log(categoryArr)
      console.log(JSON.stringify(this.aimlstory))
      if(categoryArr&&categoryArr.length){
        categoryArr.forEach(cat=>{
          // console.log(cat);
          try{
            let alicekmobj={},actionobj=[],url2obj={},urlobj={},tagobj=[];
              // console.log(cat.match(cat))
            if(cat.match(url2)){
              cat.match(url2)[0].match(getKey).forEach((str,index)=>{
                if(str.includes(' id=')) url2obj['id']=cat.match(url2)[0].match(getValue)[index].replace(/=|\"\s|\"|\/>/g,'')
                if(str.includes(' type=')) url2obj['type']=cat.match(url2)[0].match(getValue)[index].replace(/=|\"\s|\"|\/>/g,'')
                if(str.includes(' title=')) url2obj['title']=cat.match(url2)[0].match(getValue)[index].replace(/=|\"\s|\"|\/>/g,'')
                if(str.includes(' content=')) url2obj['content']=cat.match(url2)[0].match(getValue)[index].replace(/=|\"\s|\"|\/>/g,'')
                if(str.includes(' varlist=')) url2obj['varlist']=cat.match(url2)[0].match(getValue)[index].replace(/=|\"\s|\"|\/>/g,'')
                // url2obj[str.replace(/=|\s|\"/g,'')]= cat.match(url2)[0].match(getValue)[index].replace(/=|\"|\s/g,'')
              })
            }
            if(cat.match(alicekm)){
              cat.match(alicekm)[0].match(getKey).forEach((str,index)=>{
                if(str.includes('id')) alicekmobj['id']=cat.match(alicekm)[0].match(getValue)[index].replace(/=|\"\s|\"|\/>/g,'')
                if(str.includes('type')) alicekmobj['type']=cat.match(alicekm)[0].match(getValue)[index].replace(/=|\"\s|\"|\/>/g,'')
              })
            }
            if(cat.match(action)){
              // console.log(cat.match(action))
              let actionArrs=cat.match(action)
              actionArrs.forEach((item,i)=>{
                actionobj[i]={}
                item.match(getKey).forEach((str,index)=>{
                  if(str.includes('name')) actionobj[i]['action']=item.match(getValue)[index].replace(/=|\"\s|\"|\/>|\>/g,'')
                  if(str.includes('reply')) actionobj[i]['reply']=item.match(getValue)[index].replace(/=|\"\s|\"|\/>|\>/g,'')
                })
              })
            }
            if(cat.match(url)){
              cat.match(url)[0].match(getKey).forEach((str,index)=>{
                if(str.includes('title')) urlobj['title']=cat.match(url)[0].match(getValue)[index].replace(/=|\"\s|\"|\/>/g,'')
                if(str.includes('content')) urlobj['content']=cat.match(url)[0].match(getValue)[index].replace(/=|\"\s|\"|\/>/g,'')
              })
            }
            if(cat.match(tag)){
              // console.log(cat.match(tag));
              // cat.match(tag)[0].match(getKey).forEach((str,index)=>{
              //   if(str.includes('id')) tagobj['id']=cat.match(tag)[0].match(getValue)[index].replace(/=|\"\s|\"|\/>/g,'')
              //   if(str.includes('name')) tagobj['name']=cat.match(tag)[0].match(getValue)[index].replace(/=|\"\s|\"|\/>/g,'')
              // })
              cat.match(tag).forEach((iTag,itagIndex)=>{
                let o = {};
                iTag.match(getKey).forEach((str,index)=>{
                  if(str.includes('id')) o['id']=iTag.match(getValue)[index].replace(/=|\"\s|\"|\/>/g,'')
                  if(str.includes('name')) o['name']=iTag.match(getValue)[index].replace(/=|\"\s|\"|\/>/g,'')
                })
                tagobj.push(o);
              })
            }
            // console.log(url2obj,alicekmobj,actionobj)
            // console.log(cat.match(pattern)[0].replace(/<\/?pattern>/g,''))
            botArr.push({
              question:cat.match(pattern)?cat.match(pattern)[0].replace(/<\/?pattern>/g,''):'',
              msg:cat.match(template)?cat.match(template)[0].replace(/<\/?template>/g,''):'',
              that:cat.match(that)?cat.match(that)[0].replace(/<\/?that>/g,''):'',
              alicekm:cat.match(alicekm)?alicekmobj:'',
              actions:cat.match(action)?actionobj:'',
              url2:cat.match(url2)?url2obj:'',
              url:cat.match(url)?urlobj:'',
              tag:cat.match(tag)?tagobj:'',
            })
          }catch(err){
            console.log(err)
          }
        })
        // console.log(botArr)
        // console.log(this.$refs.robot)
        this.aliceBot=botArr
        if(!this.$refs.robot.records.length){
          let localBotReply=this.$refs.robot.$parent.dialogueBot('DEFAULTWELCOMETEXT');
          if(localBotReply){
            let obj={//这个怎么不用????
              msgs:localBotReply,
              contextType:2,
              question:localBotReply.question,
            }
            console.log("%c 父组件调用子组件的getLocalReply方法","background:green;color:#fff;");
            this.$refs.robot.getLocalReply(localBotReply,'DEFAULTWELCOMETEXT');
            if(this.$route.query.custom==='3'||this.$route.query.custom==='4'){
              this.manualTip = false
              this.newTipFlag = false
              this.params.sendLoginFlag = true
              this.$refs.robot.show()
            }
          }
        }
      }
    },