Exforsys

Free Training

How to modify an xml file using QTP?

This is a discussion on How to modify an xml file using QTP? within the Software Testing forums, part of the Testing category; Below is th sample xml content which needs to be modified - <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE cXML (View Source ...

Go Back   Exforsys > Testing > Software Testing

Exforsys.com


Software Testing Software testing is a process used to identify the correctness, completeness and quality of developed computer software.

Reply

 

LinkBack Thread Tools Search this Thread
  #1 (permalink)  
Old 07-02-2009, 03:31 AM
Junior Member
 
Join Date: Jan 2009
Posts: 12
ajojiraj is on a distinguished road
How to modify an xml file using QTP?

Below is th sample xml content which needs to be modified -

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE cXML (View Source for full doctype...)>
- <cXML payloadID="AN01000070707-T-AN01000125534-T22-2009-06-16T534TT002JJ102:38:54-07:00-000000369-0369-0001@edi.ariba.com" timestamp="2009-06-16T00:00:54-07:00" version="1.2.018" xml:lang="en">
- <Header>
- <From>
- <Credential domain="NetworkID">
<Identity>AN01000125534-T</Identity>
</Credential>
</From>
- <To>
- <Credential domain="NetworkID">
<Identity>AN01000070707-T</Identity>
</Credential>
</To>
- <Sender>
- <Credential domain="NetworkID">
<Identity>AN01000000001</Identity>
<SharedSecret>-=DELETED=-</SharedSecret>
</Credential>
<UserAgent>EDI Gateway</UserAgent>
</Sender>
</Header>




I need to pick the value from the tag - /Header/To/Identity
and change the value and Save the file.

How should I retrieve the tag values and modify the values?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-02-2009, 04:27 AM
Junior Member
 
Join Date: Jul 2008
Posts: 17
moonlight is on a distinguished road
we can add check points to an application using QTP. ..... An XML file can be a static data file that is accessed in order to ... time to time and/or you regularly need to update or modify test object properties.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-02-2009, 06:33 AM
Junior Member
 
Join Date: Jan 2009
Posts: 12
ajojiraj is on a distinguished road
I tried adding Checkpointon to the application but it says " You cannot perform this operation on this object"
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-03-2009, 11:10 AM
Junior Member
 
Join Date: Jul 2009
Posts: 12
basanth27 is on a distinguished road
Quote:
Originally Posted by ajojiraj View Post
I tried adding Checkpointon to the application but it says " You cannot perform this operation on this object"
You have to use the XMLUTIL object to read a xml file using QTP.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-06-2009, 05:57 AM
Junior Member
 
Join Date: Jan 2009
Posts: 12
ajojiraj is on a distinguished road
Thanks Basanth, Can you explain in detail about 'XMLUTIL object ' ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 07-06-2009, 06:21 AM
Junior Member
 
Join Date: Jul 2009
Posts: 12
basanth27 is on a distinguished road
Try this,

Set xmlDoc = CreateObject( "Microsoft.XMLDOM" )
xmlDoc.load("c:\test.xml")
Set objNodeList = xmlDoc.getElementsByTagName("PutYourTagHere")

For i = 0 To (objNodeList.length - 1)
set str = objNodeList.Item(i)
print str.text
Next

You can get tonnes of information about XMLUTIL object from the QTP Help. The above one is using API.

Try this if you want to use XMLUtil Object,

Set doc = XMLUtil.CreateXML()

doc.LoadFile "c:\example.xml"

Set root = doc.GetRootElement

msg = "My name is "

nameStr = root.ElementName()

valueStr = root.Value()

msgbox msg+nameStr + " and my value is " + valueStr


Let me know if it answers your question.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 07-06-2009, 06:39 AM
Junior Member
 
Join Date: Jan 2009
Posts: 12
ajojiraj is on a distinguished road
Basanth, I tried executing the code you had given but at the Load command, it displays the following msg - "The underlying connection was closed: Unable to connect to the remote server."
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 07-06-2009, 07:02 AM
Junior Member
 
Join Date: Jul 2009
Posts: 12
basanth27 is on a distinguished road
Paste your code please.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 07-06-2009, 07:08 AM
Junior Member
 
Join Date: Jan 2009
Posts: 12
ajojiraj is on a distinguished road
Const XMLDataFile = "D:\InvoiceLoad\Regression Testing\LeaseInvGap8OPDE_COA.xml"
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.Async = False
xmlDoc.Load(XMLDataFile)

Set node = xmlDoc.SelectSingleNode("/Header/To/Credential domain/Identity")
node.Text = "AN01000070708-T"

xmlDoc.SaveFile "D:\InvoiceLoad\Regression Testing\LeaseInvGap8OPDE_COA.xml"
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 07-06-2009, 07:17 AM
Junior Member
 
Join Date: Jul 2009
Posts: 12
basanth27 is on a distinguished road
Try this and let me know if it reads the elements,

Set xmlobj = XMLUtil.CreateXMLFromFile("D:\InvoiceLoad\Regression Testing\LeaseInvGap8OPDE_COA.xml")

rootelements = xmlobj.GetRootElement

print rootelements

This should basically print out the whole XML document.

Lets check step by step to see if we are proceeding in the right direction.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
testing of .net aplication naga_sri Testing Tutorials 1 02-16-2007 03:27 AM
Tutorial on Silk Test spriya279 Testing Tutorials 2 02-15-2007 07:31 PM
Apple II Csa2 FAQs: Uploading & Downloading, Part 21/25 rubywand@swbell.net Tech FAQ 0 05-04-2004 10:01 AM
Apple II Csa2 FAQs: Error List, Part 8/25 rubywand@swbell.net Tech FAQ 0 05-04-2004 10:01 AM
Solaris x86 FAQ 2/2 Dan Anderson Tech FAQ 0 04-27-2004 08:24 PM


All times are GMT -4. The time now is 11:19 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0
Copyright 2004 - 2009 Exforsys Inc. All rights reserved.