关于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中的。后面的读不出来。别的正常。请大家帮忙看看。很急实在没办法了