Comparing HTML Documents
Prerequisites
-
HTML Compare REST server running.
-
Two HTML or XHTML input files, or HTTP URIs pointing to them.
POST a Comparison via REST
Send a POST request to the compare pipeline endpoint:
POST /api/compare/html HTTP/1.1
Content-Type: multipart/form-data; boundary=boundary
--boundary
Content-Disposition: form-data; name="inputA"
/path/to/fileA.html
--boundary
Content-Disposition: form-data; name="inputB"
/path/to/fileB.html
--boundary
Content-Disposition: form-data; name="output"
/path/to/out.html
--boundary--
Input Specification Options
Inputs can be provided as:
|
Type |
How to specify |
|---|---|
|
File path (server-side) |
Plain text path in the form-data part (Content-Type: |
|
HTTP/HTTPS URI |
URL string in the form-data part |
|
Raw HTML string |
Inline content with Content-Type: |
Note: the output parameter only supports file paths.
Form-Data Parameters
|
Parameter |
Required |
Description |
|---|---|---|
|
|
Yes |
Original (A) HTML document |
|
|
Yes |
Revised (B) HTML document |
|
|
No |
XML configuration file (defaults to built-in defaults) |
|
|
No |
File path to write the result to |
|
|
No |
URL called when the comparison completes |
Monitor the Comparison Job
Each comparison creates an asynchronous Job. Poll for status:
GET /api/jobs/{jobId}
Job states: QUEUED → SUBMITTED → STARTED → INPUTS_LOADING_A → INPUTS_LOADING_B
→ INPUT_FILTERS → COMPARISON_RUNNING → OUTPUT_FILTERS → SAVING → FINISHED
Download the Result
When jobStatus is FINISHED, retrieve the output:
GET /api/downloads/{jobId}
The response is an XHTML redline document viewable in any browser.
Example Using curl
curl -X POST http://localhost:8080/api/compare/html \
-F "inputA=@fileA.html;type=text/plain" \
-F "inputB=@fileB.html;type=text/plain"