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 ...
|
|||||||
| Software Testing Software testing is a process used to identify the correctness, completeness and quality of developed computer software. |
![]() |
| LinkBack | Thread Tools | Search this Thread |
|
|||
|
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? |
| Sponsored Links |
|
|||
|
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.
__________________
Test Management |
|
|||
|
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. |
|
|||
|
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" |
|
|||
|
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. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| testing of .net aplication | naga_sri | Testing Tutorials | 1 | 02-16-2007 02:27 AM |
| Tutorial on Silk Test | spriya279 | Testing Tutorials | 2 | 02-15-2007 06:31 PM |
| Apple II Csa2 FAQs: Uploading & Downloading, Part 21/25 | rubywand@swbell.net | Tech FAQ | 0 | 05-04-2004 09:01 AM |
| Apple II Csa2 FAQs: Error List, Part 8/25 | rubywand@swbell.net | Tech FAQ | 0 | 05-04-2004 09:01 AM |
| Solaris x86 FAQ 2/2 | Dan Anderson | Tech FAQ | 0 | 04-27-2004 07:24 PM |