Highlighted
Absent Member.
Absent Member.
1781 views

UFT API - XML Compare

Issue : I am comparing two XML File through UFT API XML Compare activity. But, I am not able to parameterize the same.

Could you please help me to do the same for different-different XML file at run time how to do it ?

Scenario : I have to compare two XML file(Dynamic-run time) by ignoring element order.

Tried : By sorting XML through XSLT and then XMLUtil but still not giving exact result where order is changed this I can do with XML Compare activity UFT API. But here is the problem with I cann't change the File at run time.

Thanks in Advance!

Kundan Kumar

Tags (1)
0 Likes
6 Replies
Highlighted
Absent Member.
Absent Member.

Try this -

1. Add two read from file activities to canvas. Parameterize the file paths to xml file path

2. Link the output of read from file activity as input to xml compare

 

 


Accept as solution/Give Kudos to the author if the piece of information answered/helped you to solve your problem.
All the thoughts here are mine not related to my employer nor anyone.
Highlighted
Absent Member.
Absent Member.

Thanks swaroopjoshi,

I have tried the solution provided by you and it's working as expected.

But I am still facing some issues since XML COMPARE ACTIVITY is not gving exact result

For Eg -

If any element is added in a particular node of 2nd XML file then XML COMPARE ACTIVITY showing changes("Element Name Changed") for some elements in subsequent nodes. If i compare only those nodes then its working fine but giving wrong reaults  when compare whole file at once.

Please guide me. Now, using licenced version of UFT.

Thanks!

Kundan Kumar

0 Likes
Highlighted
Absent Member.
Absent Member.

Ok. IF UFT xml comparison is not working, you can try two other things -

1. Write a vbscript code to compare two xmls - this requires considerable coding skills as you will need to write recursive function to parse the xmls. Go ahead and give it a try if you are up for it and have the time.

2. There are lot of open source tools that already do xml file comparison. Just get hold of any one and invoke it from UFT. This will save your time


Accept as solution/Give Kudos to the author if the piece of information answered/helped you to solve your problem.
All the thoughts here are mine not related to my employer nor anyone.
0 Likes
Highlighted
Absent Member.
Absent Member.

Thanks for the suggestion,

We've already apply the 1st approach vbscript code to compare two XML through recursive function. But, the problem is with large file like around 70000+ lines, performance got down and some time UFT hanged up.

The 2nd approach - Could you please suggest us the tool which is easy to work with UFT and what would be the process. As we don't have access to freely install and do the R&D in office environment.

We already spend much time with XML compare thorough API. Will it not possible to continue with API approach.

Our simple requirement is to compare two XML file from two environment(So, parametrization required) with ignoring the element order facility.

Thanks you so much in advance!

Kundan Kumar

 

0 Likes
Highlighted
Absent Member.
Absent Member.

Hi swaroopjoshi,

I am still wating for fruitful response.

XMLDOM / XMLUtil - Both is not sufficient to provide exact solution. Through recursive traversing of control is huge and not compitable with large XML file where XML contains lines in lakh.

XML Compare activity through API is better and short out above problem. But, not giving correct result.

And this would be major requirement(XML Compare) for our project.

May loose comitment. 😞

Thanks!

0 Likes
Highlighted
Outstanding Contributor.
Outstanding Contributor.

Check if this article helps. Compare XML using LINQ

_____________________
Rajkumar Rajangam
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.