Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何提取XML中的所有子节点并保存在Excel中_Xml_Excel - Fatal编程技术网

如何提取XML中的所有子节点并保存在Excel中

如何提取XML中的所有子节点并保存在Excel中,xml,excel,Xml,Excel,我正在尝试从XML中提取所有子节点,需要将excel工作表中的所有节点保存在一列中。我正在excel工作表中指定XML。下面给出了XML。请任何人帮助如何提取 XML: 凯希尔 12 23 1234 233 在运行此代码之前,请添加对Microsoft XML V6.0的引用 Sub xml() Dim XDoc As MSXML2.DOMDocument Set XDoc = New MSXML2.DOMDocument XDoc.async = False

我正在尝试从XML中提取所有子节点,需要将excel工作表中的所有节点保存在一列中。我正在excel工作表中指定XML。下面给出了XML。请任何人帮助如何提取

XML:


凯希尔
12
23
1234
233

在运行此代码之前,请添加对Microsoft XML V6.0的引用

Sub xml()

    Dim XDoc As MSXML2.DOMDocument
    Set XDoc = New MSXML2.DOMDocument
    XDoc.async = False
    XDoc.validateOnParse = False
    XDoc.Load ("C:\test.xml")
    Set xEmpDetails = XDoc.DocumentElement
    Set xEmployee = xEmpDetails.FirstChild
    For Each xEmployee In xEmpDetails.ChildNodes
        For Each xChild In xEmployee.ChildNodes
            MsgBox xChild.BaseName & " " & xChild.Text
        Next xChild
    Next xEmployee
End Sub
Sub xml()

    Dim XDoc As MSXML2.DOMDocument
    Set XDoc = New MSXML2.DOMDocument
    XDoc.async = False
    XDoc.validateOnParse = False
    XDoc.Load ("C:\test.xml")
    Set xEmpDetails = XDoc.DocumentElement
    Set xEmployee = xEmpDetails.FirstChild
    For Each xEmployee In xEmpDetails.ChildNodes
        For Each xChild In xEmployee.ChildNodes
            MsgBox xChild.BaseName & " " & xChild.Text
        Next xChild
    Next xEmployee
End Sub