We can get parent and child node values with below code.
Val=GetNodeValue ( “C:\XMLfile.XML”,"ParentNodeName","ChildNodeName")
msgbox UBound(Val)
Function GetNodeValue(XMLFilePath,ParentNode,ChildNode)
Dim Obj_Xml,str_ParentNode,list_childs
Dim i,j,str_ParentNodeCnt,str_result()
set Obj_Xml=createobject("MSXml2.DOMDocument.3.0")
Obj_Xml.load XMLFilePath
set str_ParentNode=Obj_Xml.getElementsByTagName(ParentNode)
str_ParentNodeCnt=str_ParentNode.length
ReDim str_result(str_ParentNodeCnt)
msgbox str_ParentNodeCnt
For i=0 to str_ParentNodeCnt-1
set list_childs=str_ParentNode(i).childnodes
for j=0 to list_childs.length-1
If list_childs.item(j).nodename=ChildNode then
str_result(i)=list_childs.item(j).text
Exit for
end if
next
Next
GetNodeValue=str_result
End Function
Sunday, May 10, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment