Code to get attribute values from an xml

Was facing a problem in finding the attributes in an xml file, Here is the code of how to solve that:

Const XMLDataFile = "C:\Test.xml"
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.Async = False
Dim strAttribute
Set nodes = xmlDoc.SelectNodes("/Path till the node where the attribute is present")
For i = 0  To(nodes.Length -1)
      strAttribute= nodes(i).getAttribute("Attribute Name")
      MsgBox "Node #" & (i + 1)& ": " & strAttribute

Hope this helps!

1 comment:

  1. Shankar21/12/10

    Awesome i just googled your blog and found the solution.Thanks a Ton!