Code to get tagnames and values from an xml


In continuation from the previous post where we try and get the attribute values from an xml, here is the code where we get the tag names and its values :


Const xmlFile1= "C:\Test.xml"
Set xmlDoc1 = CreateObject("Msxml2.DOMDocument")
xmlDoc1.load(xmlFile1)
set nodes1 = xmlDoc1.selectNodes("//*")
for i = 0 to nodes1.length -1
        tagname1 = nodes1(i).nodeName
        val1 = nodes1(i).text
        If  tagname1= "test" Then
                msgbox tagname1
                msgbox val1
                Exit for
        End If
next

Hope this helps , happy testing!

Comments

Popular posts from this blog

Software Testing @ Microsoft

Trim / Remove spaces in Xpath?