Quick test professional

QTP Tips QTP codes QTP Faqs and more

Read XML using Dotnet Factory

Set objReader = DotNetFactory.CreateInstance(“System.Xml.XmlReader”, “System.Xml”)
set XmlReader=objReader.Create(“C:\Documents and Settings\kmohankumar\Desktop\3.xml”)

while (XmlReader.Read())

If  XmlReader.NodeType = “XmlDeclaration” or XmlReader.NodeType = “Element”Then
  
    Reporter.ReportEvent micPass, “NodeType:”&XmlReader.NodeType &”  Name :”& XmlReader.Name& ” is at Depth:”& XmlReader.Depth,”"

    If XmlReader.HasValue Then
        Reporter.ReportEvent micPass, ” Value: “& XmlReader.Value,”"
    End If

    Reporter.ReportEvent micPass, “Element:”& XmlReader.Name&”  has attribute(s)”&”:”& XmlReader.AttributeCount,”"

  If XmlReader.AttributeCount > 0 Then

        while  XmlReader.MoveToNextAttribute()
     fn = XmlReader.Name
     ns = XmlReader.NamespaceURI
      Reporter.ReportEvent micPass,” Attribute:”&fn &”  Value: “& ns&” Attribute:”& XmlReader.GetAttribute(fn, ns),”"
        wend
     End If
End If
wend
XmlReader.Close()

Author: Mohan Kakarla

November 27, 2008 - Posted by quicktestprofessional | DotNetFactory, XML Scripting | | 2 Comments

2 Comments »

  1. Hi,

    Nice blog..publish you new content url at http://www.dotneturl.com and get reader and back link form us for free.

    Comment by DotNetURL | November 27, 2008 | Reply

  2. Hi,

    Nice blog …gud to see this kind of information….
    I have to purchase QTP for functional testing… can you help me to purchase the same. Can u give me vendor details and suggest us for QTP version.

    Comment by Vinayak | April 7, 2009 | Reply


Leave a comment