XML to HTML API Documentation¶
Overview¶
The XML to HTML API converts XML data into a formatted HTML table.
It validates the XML input, parses it into a structured format, and generates a clean, styled HTML document containing a table representation of the XML data.
This API supports:
- Synchronous processing for direct XML input in the request body.
- Asynchronous processing for remote file URLs or uploaded files.
Base URL:
https://api.apidatatools.com/xml-to-html-api
Endpoint (POST)¶
POST https://api.apidatatools.com/xml-to-html-api
Headers¶
| Header | Description | Required | Example |
|---|---|---|---|
Content-Type | MIME type of the request body | Yes | application/xml |
x-api-key | Your API key for authentication | Yes | abcd1234xyz |
x-source-type | Input source type: body, url, or file | Optional (default: body) | url |
Accepted File Extensions¶
| Mode | Allowed Extensions |
|---|---|
| URL / File | txt, xml, log |
Input Example (Body Mode)¶
<employees>
<employee>
<id>1</id>
<name>John Doe</name>
<department>Engineering</department>
</employee>
<employee>
<id>2</id>
<name>Jane Smith</name>
<department>Marketing</department>
</employee>
</employees>
Input Example (URL Mode)¶
{
"url": "https://example.com/data/employees.xml"
}
Input Example (File Mode)¶
{
"file": "user_uploads/abc123/employees.xml"
}
Example Request¶
Synchronous (Body Input)¶
curl -X POST "https://api.apidatatools.com/xml-to-html-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/xml" \
-H "x-source-type: body" \
-d '<employees>
<employee>
<id>1</id>
<name>John Doe</name>
<department>Engineering</department>
</employee>
<employee>
<id>2</id>
<name>Jane Smith</name>
<department>Marketing</department>
</employee>
</employees>'
Asynchronous (Remote File URL)¶
curl -X POST "https://api.apidatatools.com/xml-to-html-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "x-source-type: url" \
-d '{"url": "https://example.com/data/employees.xml"}'
Asynchronous (Input File)¶
curl -X POST "https://api.apidatatools.com/xml-to-html-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "x-source-type: file" \
-d '{"file": "user_uploads/abc123/employees.xml"}'
Example Response¶
Successful (Body Mode)¶
Status: 200 OK
{
"status": "success",
"request_id": "f3b2a1d4-5678-4c9a-9b2a-123456789abc",
"file": "https://downloads.apidatatools.com/apidatatools_convert_abcdef1234567890.html",
"preview": "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"utf-8\"><title>XML to HTML Table</title>..."
}
Async Job Accepted¶
Status: 202 Accepted
{
"status": "accepted",
"job_id": "b1d2e3f4-5678-90ab-cdef-1234567890ab",
"status_url": "https://api.apidatatools.com/jobs/b1d2e3f4-5678-90ab-cdef-1234567890ab",
"request_id": "a9b8c7d6-1234-5678-9abc-def012345678"
}
Error Handling¶
| Error Code | HTTP Status | Message | Example Details |
|---|---|---|---|
INVALID_XML | 400 | XML validation or parsing failed | {"message": "XML parsing failed.", "line": 3, "column": 12} |
HTML_CONVERSION_FAILED | 400 | Failed to convert XML to HTML table | {"message": "Unexpected structure in XML"} |
EMPTY_BODY | 400 | Request body is empty | {"message": "Request body is empty."} |
INVALID_BODY_ENCODING | 400 | Failed to decode base64 body | {"message": "Failed to base64-decode request body."} |
PAYLOAD_TOO_LARGE | 413 | Request body exceeds plan limit | {"message": "Request body exceeds 5120KB limit for your plan."} |
INVALID_URL | 400 | Invalid or missing URL | {"message": "URL must be valid http/https."} |
URL_UNREACHABLE | 400 | Could not reach the provided URL | {"message": "Could not reach URL: HTTP error 404: Not Found"} |
URL_NOT_OK | 400 | URL did not return HTTP 200 | {"message": "URL returned HTTP 403, expected 200."} |
FILE_TOO_LARGE | 413 | File exceeds plan limit | {"message": "File exceeds plan limit."} |
INVALID_FILE_EXTENSION | 400 | Unsupported file extension | {"message": "Extension '.exe' is not allowed for 'xml-to-html-api'."} |
FILE_UNAVAILABLE | 400 | Could not access uploaded file | {"message": "Could not access file: Not Found"} |
INTERNAL_ERROR | 500 | Internal processing error | {"message": "Failed to process your request"} |
Async Job Status¶
Endpoint:
GET https://api.apidatatools.com/jobs/{job_id}
Example Status Response for Async¶
Queued / Processing¶
{
"job_id": "b1d2e3f4-5678-90ab-cdef-1234567890ab",
"status": "queued",
"created_at": 1712345678,
"updated_at": 1712345678,
"message": "Your job is being processed.",
"retry_after": 2
}
Successful¶
{
"job_id": "b1d2e3f4-5678-90ab-cdef-1234567890ab",
"status": "success",
"created_at": 1712345678,
"updated_at": 1712345690,
"result": {
"status": "success",
"file": "https://downloads.apidatatools.com/apidatatools_convert_abcdef1234567890.html",
"request_id": "f3b2a1d4-5678-4c9a-9b2a-123456789abc",
"preview": "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"utf-8\"><title>XML to HTML Table</title>..."
}
}
Failed¶
{
"job_id": "b1d2e3f4-5678-90ab-cdef-1234567890ab",
"status": "failed",
"created_at": 1712345678,
"updated_at": 1712345680,
"error": {
"code": "INVALID_XML",
"message": "XML parsing failed.",
"details": {
"message": "mismatched tag: line 4, column 5",
"line": 4,
"column": 5
}
}
}
Notes for Developers¶
- The output is a downloadable HTML file stored temporarily on a secure storage.
- The
previewfield in the response contains the first 100KB of the generated HTML for quick inspection. - For large XML files, use asynchronous mode (
x-source-type: urlorx-source-type: file). - The
status_urlreturned in async mode can be polled to check job progress. - All responses include a unique
request_idfor traceability.