XML文件如下:文件名:newtest3.xml
<? xml version ="1.0" encoding ="utf-8" ?>
< data >
         < book cost ="56" name ="科技教育" >
             < ssort id ="571" name ="箱包" >箱包 </ ssort >    
             < ssort id ="573" name ="旅行配件" >旅行配件 </ ssort >    
     </ book >
         < book cost ="62" name ="铁道教育" >
             < ssort id ="574" name ="箱包2" >箱包2 </ ssort >    
             < ssort id ="575" name ="旅行配件2" >旅行配件2 </ ssort >    
         </ book >
</ data >
ASP文件如下:
<%
         Dim node,i,nodeCount
         Set doc = Server.CreateObject( "Microsoft.XMLDOM")
        doc.async = false
        doc.load(Server.MapPath( "newtest3.xml"))
         Set root = doc.documentElement
         Set nodeLis = root.childNodes
        nodeCount = nodeLis.length
         For i = 1 to nodeCount
            
                 Set node = nodeLis.NextNode()
     Set nodeLis2 = node.childNodes
    nodeCount2 = nodeLis2.length
    
     Set cost = node.attributes.getNamedItem( "cost")
                Response.Write( "第 "&i& " 条记录:")
    Response.Write(cost.text& "</br>")
             For j = 1 to nodeCount2    
       Set node2 = nodeLis2.NextNode()
       Set zhi1 = node2.attributes.getNamedItem( "id")
       Set zhi2 = node2.attributes.getNamedItem( "name")
                        Response.Write(zhi1.text& ",")
                        Response.Write(zhi2.text)
            Response.Write( "</br>")
                         next
                Response.Write( "</br>")
         Next
%>
 
IE显示效果如下:
第 1 条记录:56
571,箱包
573,旅行配件

第 2 条记录:62
574,箱包2
575,旅行配件2