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

About these ads

November 27, 2008 - Posted by | DotNetFactory, XML Scripting

3 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

  3. Hi Mohan,

    For OpenOffice XML Form Document (.odt,sxw), do you have an idea for get attribute
    and value of these file.
    I try code following:
    Dim agr()
    Set oSM = CreateObject(“com.sun.star.ServiceManager”)
    Set oDesk = oSM.createInstance(“com.sun.star.frame.Desktop”)
    Set oDoc = oDesk.loadComponentFromURL(“file:///C:/test.odt”, “_blank”, 0, arg)
    ….
    ‘ I no idea how to get any attribute
    ….

    Set oDesk = Nothing
    Set oSM = Nothing

    thank in advice

    Comment by Manat | June 10, 2011 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 134 other followers

%d bloggers like this: