如何提取XML中的所有子节点并保存在Excel中
我正在尝试从XML中提取所有子节点,需要将excel工作表中的所有节点保存在一列中。我正在excel工作表中指定XML。下面给出了XML。请任何人帮助如何提取 XML:如何提取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
凯希尔
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