以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 精华版 』  (http://bbs.xml.org.cn/list.asp?boardid=37)
----  [020401050]DOM与ASP的接口问题?  (http://bbs.xml.org.cn/dispbbs.asp?boardid=37&rootid=&id=7709)


--  作者:yuji1998
--  发布时间:5/20/2004 3:03:00 AM

--  [020401050]DOM与ASP的接口问题?
[原作者:cmy8132]
             [疑问点击]  
我做的一个小问题是知识查询与疑难问题系统,用的是asp和xml做的,其中的查询模块如下实现,如果用C,C++如何实现?
<html>t="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>查询结果</title>
<script language="javascript" type="text/javascript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head>

<body bgcolor="#000000">
<div align="center">
  <center>
  <table border="0" width="611" cellspacing="0" cellpadding="0" height="528" background="images/i-3-1.gif">
    <!--DWLayoutTable-->
    <tr>
      <td width="609" height="539" valign="top" background="images/t-02.gif">
        <div align="right">
          <table border="0" width="91%" cellspacing="5" cellpadding="5" height="477">
            <!--DWLayoutTable-->
            <tr>
              <td width="1" height="80"></td>
              <td width="100%"> <p align="center"><font color="#FF3366" size="4" face="仿宋_GB2312"><em><strong>我
                   们 一 直 在 努 力</strong></em></font></td>
            </tr>
            <tr bgcolor="#006666">
              <td height="61" colspan="2" valign="top"><div align="center"><font color="#00FF00" size="6"><strong>问题答案是</strong></font></div></td>
            </tr>
            <tr>
              <td height="349" colspan="2" valign="middle" bgcolor="#006460">
                <div align="left">
                  <form name="form1" method="post" action="">
                    <p>

              <%
      question=request.form("std_question")
      question=trim(question)
      length=len(question)
      question=left(question,length-4)
      keywords=SPLIT(question,"的")
     keyword_num=ubound(keywords)+1
     Set DomXML=Server.CreateObject("MSXML.DOMDocument")
     DomXML.Load "d:/知识查询与疑难问题系统/ds.XML"
     Set root=DomXML.documentElement
     set childNodes=root.selectNodes("//"&keywords(0)) '查找符合第一个关键字的所有节点
     if childNodes.length=0 then response.Write "<font color='#FF3366'>"&"对不起,找不到你要的问题的答案!" &"</font>"

     dim stack()
     redim stack(100,1)
     top=0
     for i=0 to childNodes.length-1
         set child=childNodes.item(i)
         set stack(top,0)=child
         stack(top,1)=0
         top=top+1
     next

     answer_order=1
     while top>0
         top=top-1
         set parent=stack(top,0)
         key_i=stack(top,1)
         if key_i+1=keyword_num then  '关键字匹配完毕
                   answer=question
                   answer=CStr(answer_order)&"."&answer
                   answer_order=answer_order+1
                   set answerNodes=parent.childNodes
                   if answerNodes.length>1 then
                      answer=answer&"可分为:"
                   else
                      answer=answer&"是:"
                   end if
                   for m=0 to answerNodes.length-2
                        set child=answerNodes.item(m)
                        if child.nodeType=1 or child.nodetype=2 then         'Current node is element node
                          answer=answer&child.nodename&"、"
                        elseif child.nodeType=3 or child.nodeType=4 then
                          answer=answer&"
"&child.text&"
"
                        end if
                   next
                   set child=answerNodes.item(m)
                   if m>0 then
                     if child.nodeType=1 then
                        answer=answer&"和"&child.nodeName&"。<hr>"
                     elseif child.nodeType=3 or child.nodeType=4 then
                       answer=answer&"和"&child.text&"。<hr>"
                     end if
                   else
                      if child.nodeType=1 then
                        answer=answer&child.nodeName&"。<hr>"
                      elseif child.nodeType=3 or child.nodeType=4 then
                        answer=answer&child.text&"。<hr>"
                      end if
                   end if
                   response.Write "<font color='#FF3366'>"&answer&"</font>"
         else
         set childSet=parent.childNodes
         finded=FALSE
         for j=0 to childSet.length-1
            set child=childSet.item(j)
            childName=child.nodeName
            if strcomp(childName,keywords(key_i+1))=0 then
               set stack(top,0)=child
               stack(top,1)=key_i+1
               top=top+1
               finded=TRUE
            end if
         next
         if finded=FALSE then
            for k=0 to childSet.length-1
               set child=childSet.item(k)
               set stack(top,0)=child
               stack(top,1)=key_i
               top=top+1
            next
         end if
        end if
     wend
     %>


                         </p>
                    </form>
                  <p>
                    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="144" height="39">
                      <param name="movie" value="button3.swf">
                      <param name="quality" value="high">
                      <param name="base" value=".">
                      <param name="bgcolor" value="#006666">
                      <embed src="button3.swf" width="144" height="39" base="."  quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" bgcolor="#006666"></embed>
                    </object>
                  </p>
                </div></td>
                
            </tr>
            <tr>
              <td height="36" colspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
                  <!--DWLayoutTable-->
                  <tr>
                    <td width="383" height="26" valign="top">   <font color="#66FFFF" size="4">      </font></td>
                    <td width="151" valign="top"><div align="center"><a href="main.htm"><font color="#33FFFF">返回</font></a></div></td>
                  </tr>
                </table></td>
            </tr>
          </table>
        </div></td>
      <td width="2"></td>
    </tr>
  </TABLE>
<CENTER>
  </DIV>
</CENTER></BODY></HTML>



W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
93.750ms