HTML Comparisons

HTML Comparisons

To invoke a comparison, you POST parameters to the specified HTML Compare pipeline, in either JSON or XML form.

POST /api/compare/html
Content-Type: application/json

Comparison Example

Here is a simple synchronous example (asynchronous comparison is detailed in more detail on this page):

Request (XML)
<compare>
  <inputA type="file">
    <path>samples/compare/html/inputA.html</path>
  </inputA>
  <inputB type="file">
    <path>samples/compare/html/inputB.html</path>
  </inputB>
  <configuration type="file">
    <path>samples/compare/html/sample-configuration.xml</path>
  </configuration>
</compare>
Request (JSON)
{
  "inputA": {
    "type": "file",
    "path": "samples/compare/html/inputA.html"
  },
  "inputB": {
    "type": "file",
    "path": "samples/compare/html/inputB.html"
  },
  "configuration": {
    "type": "file",
    "path": "samples/compare/html/sample-configuration.xml"
  }
}

The response below indicates the comparison result, in this case a HTML file describing the changes between the inputs specified in the request.

Response
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
    <head>
        ...
    </head>
    <body>
        <h1 id="heading">HTML Compare</h1>
        <p>HTML Compare enables you to compare any HTML
            <ins class="deltaxml-new" style="background:green">/XHTML</ins> documents or data and view the changes in a xhtml
            <ins class="deltaxml-new" style="background:green">red line </ins>output.
        </p>
        <h2 class="sub-heading">What does HTML Compare do?</h2>
        <p>HTML Compare offers a REST API for comparison of HTML content. Our comparison tool generates an
    XHTML output, after comparing any HTML or XHTML inputs. Our sophisticated tool allows for users to view the
    highlighted changes between two inputs for all kinds of HTML content. With this configurable tool
    users can also control how they visualize the difference between their inputs with ease.
    See our technical specification page for details on how to you can best use HTML Compare.
        </p>
    </body>
</html>

Comparison Model

When specifying a comparison, these are the various available objects:

Object

Description

inputA

(required)

Input A to the comparison.

See this page for the various I/O types available. 

inputB

(required)

Input B to the comparison.

See this page for the various I/O types available. 

configuration

Configuration to the comparison

See this page for more information on configuration files.

See this page for the various I/O types available.

async

output

Specification of where the comparison result will be written.

See this page for the various I/O types available. 

callback

URL that will be polled after the comparison is complete.

See Callbacks in Async for more information.

Form Input

In addition to requests in structured XML or JSON format, multipart/form-data can also be used.

For example:

Request
POST /api/compare/html
Content-Type: multipart/form-data; boundary=boundary-id
Content-Length: number_of_bytes_in_entire_request_body

--boundary-id
Content-Disposition: file; filename="file1.xml"
Content-Size: 98344
Content-Type: application/xml

... XML  ...
--boundary-id
Content-Disposition: file; filename="file2.xml"
Content-Size: 92224
Content-Type: application/xml

... XML  ...
--boundary-id
Content-Disposition: file; filename="configuration.xml"
Content-Size: 32224
Content-Type: application/xml

... XML  ...
--boundary-id

Content-Disposition: form-data; name="async"
true
--boundary-id

The following table describes the parts that can make up the form-data:

Parameter

Description and example usage

inputA (required)

Input A

Can be specified in either a file path, a HTTP URI, or raw XML

inputB (required)

Input B

Can be specified in either a file path, a HTTP URI, or raw XML

configuration

Configuration file

Can be specified in either a file path, a HTTP URI, or raw XML

async

Whether async comparison is used.

Default value if not specified: false

output

An optional file path to write the output to when using async.

E.g. "/Users/exampleUser/Documents/test.xml"

callback

Callback URL called after comparison is complete.

Note : only used with asynchronous comparisons. See this page.