标题:关于Asp读取XML
只看楼主
zjbnyist
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2006-11-19
 问题点数:0 回复次数:1 
关于Asp读取XML
<questionList>
  <item>
    <questionId>001</questionId>
    <questiontype>1</questiontype>
    <questionContent>aibaobao</questionContent>
    <answerList>
      <item>
        <answerCode>001</answerCode>
        <answerName>A.ai</answerName>
      </item>
       <item>
        <answerCode>002</answerCode>
        <answerName>B.buai</answerName>
      </item>
      <item>
        <answerCode>003</answerCode>
        <answerName>C.aibuai</answerName>
      </item>
    </answerList>
  </item>
   <item>
    <questionId>002</questionId>
    <questiontype>2</questiontype>
    <questionContent>baobao</questionContent>
    <answerList>
       <item>
        <answerCode>001</answerCode>
        <answerName>A.dao</answerName>
      </item>
       <item>
        <answerCode>002</answerCode>
        <answerName>B.meidao</answerName>
      </item>
       <item>
        <answerCode>003</answerCode>
        <answerName>C.meidoadoa</answerName>
      </item>
       <item>
        <answerCode>004</answerCode>
        <answerName>D.hehe</answerName>
      </item>
    </answerList>
  </item>
</questionList>
以上是XML数据。
下边是代码:
dim para,dabm,asbm,MyArray
Set objXML2 = Server.CreateObject("Msxml2.DOMDocument")   
objXML2.async = False   
loadResult=objXML2.load(server.MapPath("d.xml"))
if not loadResult then   
    Response.write "装载XML文件错误"   
    Response.end   
end  If   
set objnodes=objXML2.documentElement.SelectSingleNode("//questionList/item/").ChildNodes
for each element in objnodes
   strID = element.SelectSingleNode("questionId").text
   response.Write element.SelectSingleNode("questiontype").text
   strWt = element.SelectSingleNode("questionContent").text
set objnodes1=objXML2.documentElement.SelectSingleNode("//questionList/item/answerList").ChildNodes
  for each element1 in objnodes1
  asbm=element1.SelectSingleNode("answerCode").text
  dabm=element1.SelectSingleNode("answerName").text
 next
next
读出来的第二个For循环总是读出三项,第一个answerlist中的。后面的读不出来。别的正常。请大家帮忙看看。很急实在没办法了
搜索更多相关主题的帖子: XML Asp 
2008-09-09 15:24
anlige
Rank: 3Rank: 3
等 级:新手上路
威 望:7
帖 子:401
专家分:0
注 册:2006-11-3
得分:0 
set objnodes1=element.getElementsByTagName("answerList")
  for each element1 in objnodes1
  asbm=element1.SelectSingleNode("answerCode").text
  dabm=element1.SelectSingleNode("answerName").text
 next

http://www.
zhanghuiguoanlige@
2008-09-09 19:28



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-232322-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.139633 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved