SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 2 of 2
  1. #1
    Junior Member
    Join Date
    Feb 2008
    Posts
    2
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    reading an XML file in QTP

    Hi. I am a newbie to QTP. I have created an xml file as follows and saved it as xml1.xml
    <?xml versiion="1.0" encoding="UT-8"?>
    <class_list>
    <student>
    <name>Steve</name>
    <grade>A</grade>
    </student>
    <student>
    <name>Mellisa</name>
    <grade>A-</grade>
    </student>
    </class_list>
    Now I am trying to create an object of msxml2 class using vb script withing qtp(expert view).the code is as follows:


    Dim describe, filepath
    Dim xmlDoc
    Set xmlDoc = CreateObject(”Msxml2.DOMDocument”)
    xmlDoc.load(”"C:\Tests\xml-qtp\xml1.xml"”)
    Set ElemList = xmlDoc.getElementsByTagName(”class_list”)
    filepath = ElemList.item(0).getAttribute(”filePath”)
    MsgBox filepath

    when I am writing this code in a test in QTP, it is not recognizing the of the classes or associated methods. I chose visual basic, activeX and Web add-ins from start up window.all the basic vbs things like dim statements, msgbox etc. are identifiable by qtp, but when it comes to creating objects and using classes as mentioned above, not working.

    My first concern is qtp is not identifying or highlighting any class such as Msxml2 etc. naturally all other objects and methods are not working.

    1)any clue what could be the problem?
    2)Please help me through the steps of reading data from an xml file in qtp and send the output of the test to another xml file.
    3)when I create my xml file and try to open it through IE, it shows the above xml structure in IE. is this the expected output or the output of this xml file in IE should be displayed in a different way?

    4) while reading xml and sending outout to another xml file,what do I have to set in the "record and run setting" option...since there are only two options web or windows applications to choose from.
    any help is highly appreciated.

    Anjali
    [img]/images/graemlins/confused.gif[/img]

  2. #2
    Senior Member
    Join Date
    Jan 2006
    Location
    Stockholm, Sweden
    Posts
    371
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: reading an XML file in QTP

    1) Your XML has an invalid header and the elements and attributes in your code does not match your XML. Also change
    xmlDoc.load(”"C:\Tests\xml-qtp\xml1.xml"”) to xmlDoc.load("C:\Tests\xml-qtp\xml1.xml").
    2) Well, you are in the right direction...what data do you want to output?
    3) IE usally displays XML correctly, however sometimes problem occurs with special characters
    4) Use Record/Run to any open ...

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 11.54%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 11:51 AM.

Copyright BetaSoft Inc.