Sub 下载XML数据()
    Dim http As Object, nod, nod2
	'Set http = CreateObject("Microsoft.XMLHTTP")'拒绝访问
    Set http = CreateObject("MSXML2.ServerXMLHTTP")
    http.Open "get", "http://zx.500wan.com/static/info/kaijiang/xml/ssq/12019.xml", False
    http.Send
    i = 0
    For Each nod In http.responseXML.getElementsByTagName("xml")
        For Each nod2 In nod.ChildNodes
            i = i + 1
            Cells(i, 1) = nod2.nodeName
            Cells(i, 2) = nod2.Text
        Next
    Next
    a = Array("RedFX", "BlueFX", "TiDian")
    For p = 0 To 2
        i = Range("a65536").End(xlUp).Row
        For Each nod In http.responseXML.getElementsByTagName(a(p))
            For Each nod2 In nod.Attributes
                i = i + 1
                Cells(i, 1) = nod2.Name
                Cells(i, 2) = nod2.Text
            Next
        Next
    Next p
End Sub
 
 
                   
                   
                   
                   
                            
 
                             本文介绍了一个使用VBA脚本从XML文件中提取数据的方法,通过编写Sub过程下载XML数据,解析并填充Excel表格。脚本利用了Microsoft.XMLHTTP对象和MSXML2.ServerXMLHTTP对象来实现HTTP请求,遍历XML节点获取所需信息。
本文介绍了一个使用VBA脚本从XML文件中提取数据的方法,通过编写Sub过程下载XML数据,解析并填充Excel表格。脚本利用了Microsoft.XMLHTTP对象和MSXML2.ServerXMLHTTP对象来实现HTTP请求,遍历XML节点获取所需信息。
           
       
           
                 
                 
                 
                 
                 
                
               
                 
                 
                 
                 
                
               
                 
                 扫一扫
扫一扫
                     
              
             
                   4977
					4977
					
 被折叠的  条评论
		 为什么被折叠?
被折叠的  条评论
		 为什么被折叠?
		 
		  到【灌水乐园】发言
到【灌水乐园】发言                                
		 
		 
    
   
    
   
             
            


 
            