compare xml files

  • 0
  • 2
  • Question
  • Updated 2 years ago
  • Answered
Hi 
I have two xml files from 2 QuickBase Tables. both are similarly structured. They have 2 key attributes (PatiendId, Transaction Date). I need to develop a efficient mechanism to compare the two xml objects and identify how many patientid and transaction from table 1 exist in table 2. I am conversant with jquery and javascript and can run this in quickbase. I can do it by iterative method (like read from one xmls and then iterate other to find duplicates but i am looking for a efficient method) but i feel xml will have some better mechanism to give me the duplicates ?
Any help would be appreciated.

thanks & regards
dinesh
Photo of Dinesh

Dinesh

  • 202 Points 100 badge 2x thumb

Posted 2 years ago

  • 0
  • 2
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,064 Points 20k badge 2x thumb
You can make the job a little easier by using API_GenResultsTable&jsa=1 to return arrays instead of XML. The compare the two responses using Underscore's difference() method like this:

var url1 = "https://login.quickbase.com/db/6ewwzuuj?act=API_GenResultsTable&qid=6&clist=3&jsa=1";
var url2 = "https://login.quickbase.com/db/6ewwzuuj?act=API_GenResultsTable&qid=7&clist=3&jsa=1";

$.getScript(url1)
  .then(function() {
    var data1 = qdb_data;

    $.getScript(url2)
      .then(function() {
        var data2 = qdb_data;
        console.table(_.difference(data1, data2));
      });

  });
This example can be executed from the console of the Formula Functions Reference table and returns the rids of those records in the first query but not the second:

Formula Functions Reference Home
https://login.quickbase.com/db/6ewwzuuj?a=td

You can further modify the reporting logic to identify those specific records with specific combinations of [PatiendId], [Transaction Date] field values that you are interested in seeing in the report.

See also Underscore's union() and intersection() methods.
(Edited)
Photo of Charlie

Charlie

  • 316 Points 250 badge 2x thumb
If script writing isn't your forte, you could try a tool like kdiff: http://kdiff3.sourceforge.net/
Photo of Dinesh

Dinesh

  • 202 Points 100 badge 2x thumb
Thanks Dandie and Charlie. I could achieve the required task. Thanks for support.