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
xmlDoc.Load(XMLDataFile)
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
Next



Hope this helps!

Comments

  1. Shankar21/12/10

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

    ReplyDelete

Post a Comment

Popular posts from this blog

Software Testing @ Microsoft

Trim / Remove spaces in Xpath?