Use below code and get each node name and value of XML file.
Read all the nodes and their values in the xml file:-
Set xmlobj=createobject("Msxml2.DOMDocument.3.0")
xmlobj.load "C:\ FileName.xml"
set ndRoot=xmlobj.documentElement
'msgbox ndRoot.nodeName
Set ndChilds=ndRoot.childNodes
intRow=1
For i=2 to ndChilds.length-1
set ndChild=ndChilds.item(i) 'general
Call fnChildNodes(ndChild)
Next
'Function that reads the node name and node value of a node including all its child nodes.
Function fnChildNodes(ndChild)
If ndChild.childNodes.length>0 then
datatable.SetCurrentRow(intRow)
datatable("NodeName",1)=ndChild.nodeName
set ndGrdChilds=ndChild.childNodes
If ndGrdChilds.item(0).nodeName="#text" Then
datatable("NodeValue",1)=ndChild.text
End If
intRow=intRow+1
set ndGrdChilds=ndChild.childNodes
If ndGrdChilds.item(0).nodeName<>"#text" Then
For j=0 to ndGrdChilds.length-1
set ndGrdChild=ndGrdChilds.item(j)
Call fnChildNodes(ndGrdChild)
Next
End IF
else
datatable.SetCurrentRow(intRow)
datatable("NodeName",1)=ndChild.nodeName
intRow=intRow+1
End If
End Function
Friday, October 15, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment