Invoice Data Extraction Logo
Invoice Data Extraction
Start Extraction
Pricing
Extraction Guide
API
Sign inCreate account
Sign inCreate account
Start Extraction
Pricing
Extraction Guide
API
  1. Home
  2. Articles & Analysis
  3. Invoice Data Extraction
  4. ZATCA Invoice XML Extraction: An AP Workflow

ZATCA Invoice XML Extraction: An AP Workflow

Extract ZATCA invoice data from UBL 2.1 XML or PDF/A-3, map fields for review, reconcile QR and PDF values, and route mixed-format exceptions.

Published
Aug 16, 2026
Updated
Aug 16, 2026
Reading Time
16 min
Author
David Harding
Topics:
Invoice Data ExtractionSaudi ArabiaZATCAUBL 2.1XML invoicingPDF/A-3

On this page

For ZATCA invoice XML extraction, parse the UBL 2.1 XML as the primary data source whenever it is present. Keep repeating invoice lines as rows, retain the original artifact and its identifiers, and use the human-readable PDF and decoded QR payload to reconcile selected values. Schema checks, arithmetic checks, cryptographic verification, and AP approval remain separate controls.

That distinction matters because extraction answers a narrow question: what values does this artifact declare? It does not prove that the signature is valid, the invoice was cleared or reported successfully, the VAT treatment is correct, or the document is approved for payment. A parser can accurately return an invoice number and total from a file that later fails a business rule or cryptographic check.

For a received Saudi supplier invoice, the practical workflow is therefore XML first, comparison second, validation through the appropriate control services, and AP review last. A PDF/A-3 file may package the same UBL payload beside a visual rendering. A plain PDF or scan may contain only pixels or selectable text, in which case OCR becomes an exception path rather than the default extraction method.

The review dataset should preserve the invoice-level identity, repeating line structure, source location, and a pointer to the untouched received file. Those elements allow finance and systems teams to trace a row back to the cleared artifact, distinguish source data from normalized values, and route each disagreement to the team that owns it.

Decide which inbound artifact contains the authoritative data

Route the file according to what it actually contains, not its extension or appearance.

Inbound artifactPrimary extraction sourceWhat to verify first
Raw UBL XMLThe XML itselfThe file is well formed, its root and namespaces identify the expected UBL invoice, and the received bytes are preserved with a recorded checksum; cryptographic integrity is assessed later
PDF/A-3 with embedded XMLThe embedded XML attachmentThe attachment collection contains an accessible XML file that can be opened and parsed
Visual PDF without accessible XMLSelectable text or OCR outputNo usable XML attachment exists and the page content belongs to the invoice rather than a cover sheet or rendering artifact
Image-only PDF, JPG, or PNGOCR outputPage quality, orientation, language, and document boundaries support reliable recognition

A PDF should not be classified as an XML-bearing invoice merely because it has a .pdf filename, searchable text, or a visible QR code. Inspect its embedded-file or attachment collection. Extract the attachment to a controlled working area, confirm that it is XML, and parse it without modifying the received container. If the attachment is missing, corrupt, or inaccessible, record that condition before using the visual layer as a fallback.

This XML-first decision follows the structure of the regime itself. ZATCA's detailed e-invoicing guideline describes e-invoicing as the exchange and processing of invoices in a structured electronic format, with official examples that include XML and human-readable PDF/A-3 files containing embedded XML. The PDF representation helps a person read the invoice; it does not replace the structured payload when that payload is available.

The container idea is similar to how hybrid PDF/XML invoices work in ZUGFeRD: one artifact can carry both a visual representation and machine-readable invoice data. The profiles, business rules, and validation authorities differ, so that comparison explains the packaging pattern rather than making the formats interchangeable.

Mandate phases and invoice-content rules should stay outside the intake decision. Teams that need that background can use the separate guide to Saudi Arabia VAT invoice requirements. For inbound processing, the decisive question is simpler: does this received artifact contain an accessible structured payload, and can the untouched source be preserved while it is parsed?

Map ZATCA business terms to a review-ready field set

UBL parsing must be namespace-aware. The familiar cbc and cac prefixes are aliases used in the standard; a supplier's XML can use different prefix names for the same namespace URIs. Resolve the namespaces, select the Invoice root, and treat the paths below as relative to that root.

Review fieldZATCA business termRelative UBL pathNormalization note
Invoice numberBT-1cbc:IDPreserve the source string; do not coerce leading zeros away
UUIDKSA-1cbc:UUIDKeep separate from the supplier's invoice number
Issue dateBT-2cbc:IssueDateParse to an ISO date while retaining the raw value
Issue timeKSA-25cbc:IssueTimePreserve the supplied time-zone form, including AST or UTC notation
Invoice typeBT-3cbc:InvoiceTypeCodeStore the code and its attributes before deriving a display label
Invoice currencyBT-5cbc:DocumentCurrencyCodeValidate as a currency code; do not infer it from a symbol in the PDF
Seller legal nameBT-27cac:AccountingSupplierParty/cac:Party/cac:PartyLegalEntity/cbc:RegistrationNamePreserve Arabic and English forms separately when both exist
Seller VAT identifierBT-31cac:AccountingSupplierParty/cac:Party/cac:PartyTaxScheme/cbc:CompanyIDKeep as text and retain all digits
Buyer legal nameBT-44cac:AccountingCustomerParty/cac:Party/cac:PartyLegalEntity/cbc:RegistrationNameEvaluate required presence against the invoice type and applicable rule
Buyer VAT identifierBT-48cac:AccountingCustomerParty/cac:Party/cac:PartyTaxScheme/cbc:CompanyIDAbsence can be context-dependent; never manufacture a value
Total VATBT-110cac:TaxTotal/cbc:TaxAmountRetain the currencyID attribute and distinguish invoice from accounting currency totals
VAT taxable amountBT-116cac:TaxTotal/cac:TaxSubtotal/cbc:TaxableAmountOne row can exist for each VAT category breakdown
VAT category taxBT-117cac:TaxTotal/cac:TaxSubtotal/cbc:TaxAmountJoin it to the category and rate from the same TaxSubtotal
VAT category and rateBT-118, BT-119cac:TaxTotal/cac:TaxSubtotal/cac:TaxCategory/cbc:ID and cbc:PercentKeep category codes distinct from percentages
Sum of invoice line net amountsBT-106cac:LegalMonetaryTotal/cbc:LineExtensionAmountReconcile to the sum of BT-131 line net amounts
Total before VATBT-109cac:LegalMonetaryTotal/cbc:TaxExclusiveAmountCompare with the line, allowance, and charge calculation
Total with VATBT-112cac:LegalMonetaryTotal/cbc:TaxInclusiveAmountDo not substitute the amount due when prepayments or rounding exist
Prepaid, rounding, amount dueBT-113, BT-114, BT-115cac:LegalMonetaryTotal/cbc:PrepaidAmount, cbc:PayableRoundingAmount, cbc:PayableAmountStore each component separately
Invoice line IDBT-126cac:InvoiceLine/cbc:IDUse with the invoice key to identify a line
Quantity and unitBT-129cac:InvoiceLine/cbc:InvoicedQuantity and its unitCode attributeParse the decimal and retain the unit code
Line net amountBT-131cac:InvoiceLine/cbc:LineExtensionAmountRetain currencyID and reconcile to document totals
Item nameBT-153cac:InvoiceLine/cac:Item/cbc:NamePreserve the original Unicode text
Line VAT category and rateBT-151, BT-152cac:InvoiceLine/cac:Item/cac:ClassifiedTaxCategory/cbc:ID and cbc:PercentDo not infer a missing category from the percentage alone
Item net price and base quantityBT-146, BT-149cac:InvoiceLine/cac:Price/cbc:PriceAmount and cbc:BaseQuantityUse both values when recalculating a unit price
Line VAT amountKSA-11cac:InvoiceLine/cac:TaxTotal/cbc:TaxAmountKeep separate from the line amount including VAT

The table is an extraction map, not a replacement for the rules. ZATCA's current Electronic Invoice XML Implementation Standard defines the UBL 2.1 syntax, EN 16931-derived business terms, KSA-specific rules, calculations, and validation phases. Its Data Dictionary and Schematron rules remain authoritative for cardinality and conditions. A buyer VAT number, for example, must be assessed in the invoice's actual context rather than treated as universally present.

This is also why a country-specific field map is more useful than copying a vendor sample. Samples show one valid shape, while the standard covers optional elements, repeating groups, invoice types, allowances, charges, prepayments, and conditional requirements. The broader guide to how UBL compares with other invoice data schemas helps place these paths in context, but the ZATCA rule set governs the Saudi profile.

Keep invoice headers, line rows, and provenance connected

A review dataset needs two grains: one record per invoice and one record per invoice line. They may be separate database tables, separate workbook sheets, or two logical datasets in a pipeline, but they should share an internal invoice key that does not depend solely on the supplier's invoice number.

The invoice record should contain the source filename or object key, source type, invoice number, UUID, invoice type code, issue date and time, document currency, supplier identity and VAT identifier, buyer identity where supplied, tax totals, monetary totals, and a pointer to the untouched original. Add operational metadata such as parser version, schema or rule-set version, extraction timestamp, extraction status, and exception code. Record a clearance or reporting identifier only when it is present in authoritative evidence; do not create one from a filename or QR value.

The line dataset should hold the internal invoice key, line ID, item description, quantity, unit code, price, base quantity, net line amount, tax category, tax rate, and line tax amount. A normalized design avoids copying every header field onto every row. For a flat Excel review sheet, repeating the invoice key, invoice number, UUID, supplier VAT identifier, currency, and source pointer on each line is a reasonable tradeoff because a filtered row remains traceable.

One row per invoice works for header-level AP review but discards line repetition if descriptions or values are concatenated into cells. One row per line preserves spend and tax detail, yet totals must not be summed naively across repeated header columns. Label the grain, separate document totals from line amounts, and make the join relationship explicit.

Keep source values beside normalized values. The raw issue date, decimal string, currency code, Arabic or English name, and identifier provide audit evidence; parsed dates, typed decimals, standardized codes, and display labels make the data usable. If normalization fails, retain the raw value and attach an exception instead of silently replacing it.

This structure supports a UBL 2.1 Saudi invoice to Excel workflow without pretending Excel is the authoritative invoice. The spreadsheet is a review and transfer surface. The XML or XML-bearing PDF/A-3 remains the source artifact from which the rows were derived.

Reconcile XML, PDF, and QR without overstating the result

Use the XML as the source record, then compare selected identity and amount fields with the PDF rendering and decoded QR payload. The shared business-value set is narrow: seller name, seller VAT registration number, invoice timestamp, invoice total including VAT, and VAT total.

ZATCA QR content is a Base64-encoded sequence of tag-length-value tuples. Tags 1 through 5 carry those five business values. Under the current security specification, the later tags carry the invoice hash and cryptographic material: the ECDSA signature, public key, and the technical authority's signature over that public key where applicable. Decode bytes according to the specification before comparing normalized values; do not compare the printed Base64 string with XML text.

DisagreementPlausible causeRouting action
XML total differs from the PDF totalStale rendering, transformation error, or altered visual layerHold the invoice; retain both artifacts and send the evidence to the supplier or e-invoicing integration owner
XML seller VAT number differs from QR tag 2QR generated from different source data, wrong attachment, or corrupted document assemblyStop automated matching and route to the e-invoicing validation owner
Timestamp looks different but represents the same instantAST versus UTC notation, formatting, or time-zone normalizationCompare parsed instants and retain both raw values before raising an exception
QR is missing or unreadableRender quality, damaged page, or a document-type and rule-context issueRecord the missing evidence and evaluate it under the applicable invoice rules; do not invent QR data
Hash or signature verification failsPayload alteration, wrong verification input, invalid certificate path, or revoked or expired credentialQuarantine the artifact and route it to the cryptographic or e-invoicing component owner

Matching tags 1 through 5 proves only that the decoded QR values agree with the selected XML and PDF values after controlled normalization. It does not validate the document hash, ECDSA signature, certificate chain, certificate status at signing time, clearance or reporting response, UBL schema, ZATCA business rules, or VAT calculation.

Those cryptographic checks require the canonicalization, transforms, hashing, certificate-path validation, and revocation checks set out in ZATCA's Security Features Implementation Standards. A QR reader or AP workbook can expose evidence for comparison. It cannot replace a compliant verification component.

Route failures by control family and owner

A single valid flag collapses evidence that comes from different systems and belongs to different owners. Store independent statuses so a successfully parsed invoice can still be held for a rule, signature, commercial, or payment issue.

Control familyWhat it testsTypical evidenceOwnerFailure route
XML and ZATCA rulesXML well-formedness, UBL 2.1 schema, code lists, EN 16931-derived rules, and KSA-specific business rulesParser output, schema errors, Schematron assertions, rule-set versionIntegration or data engineering for parsing; tax/compliance or a validated rule service for business rulesQuarantine the payload, retain the error detail, and return it to the supplier or integration owner as appropriate
Arithmetic and business-value reconciliationLine extensions, allowances, charges, tax subtotals, document totals, and agreement among XML, PDF, and QR valuesRecalculation results and field-level comparison recordsFinance systems or tax operationsHold the affected record for value investigation; never overwrite the source to make totals agree
Cryptographic and platform evidenceInvoice hash, ECDSA signature, certificate path and status, and applicable clearance or reporting evidenceVerification result, certificate chain, revocation response, platform response identifierSecurity, the e-invoicing integration, or another compliant verification componentQuarantine and prevent release until the evidence is resolved or a new authoritative artifact is received
Internal AP approvalSupplier master match, duplicates, PO and receipt match, coding, approval authority, and payment statusERP and workflow recordsAccounts Payable and business approversPlace an AP hold, request supporting information, or reject under the organization's payment controls

Use statuses that describe the evidence: parsed, schema failed, business rule failed, values disagree, cryptographic verification failed, AP hold, and approved for payment. Missing evidence should remain missing or pending, not be converted to a pass. The record can carry more than one status because the controls answer different questions.

Ownership should be equally explicit. Data engineering can repair a namespace or parser problem but should not decide whether a KSA tax rule is satisfied. Tax or a validated rule service can interpret business-rule failures but should not waive a broken signature. AP can approve the commercial transaction but cannot turn an unverified artifact into cryptographic evidence.

An extraction-ready record is therefore not automatically payment-ready, tax-valid, or cryptographically verified. Release depends on the statuses required by the organization's risk policy and the invoice's actual regulatory context.

Handle bilingual display and image-only exceptions separately

Arabic and English values can be extracted correctly from XML yet appear wrong in a spreadsheet or review interface. Unicode bidirectional rendering may move punctuation, signs, brackets, or number sequences visually even though the underlying character order has not changed. Treat that as a presentation defect until a byte-level or code-point comparison shows the source value itself differs.

Preserve the raw Unicode string and apply an explicit text direction to the display component when the field's language is known. Isolate identifiers, VAT numbers, dates, and monetary values from surrounding right-to-left text so neutral characters do not inherit an unexpected direction. Test copy and paste, CSV and XLSX export, search, sorting, and field comparison in addition to the on-screen rendering.

When the XML carries Arabic and English names, keep them in separate fields with their language or role recorded. Do not replace the Arabic legal name with a transliteration, merge both variants into one comparison key, or write a visually reordered display string back to the source-value column. Matching logic can use a controlled normalized form while retaining both originals.

OCR belongs on a separate exception path. A visual PDF with no accessible XML attachment, an image-only PDF, or a JPG or PNG can still be processed, but the resulting values are observations from the rendered document rather than values parsed from the structured payload. Mark the source method, confidence or review state, page reference, and any manual correction, then feed those values into the same normalization and reconciliation controls.

This separation prevents a bidirectional display bug from being mislabeled as XML corruption and prevents an OCR result from being treated as cleared structured data. Arabic bilingual invoice XML processing is primarily a Unicode, field-model, and interface problem; OCR quality becomes relevant only when the structured payload is genuinely unavailable.

Preserve the cleared artifact for the applicable retention period

Archive the received XML or PDF/A-3 unchanged. The archive record should contain a stable object identifier, cryptographic checksum, receipt timestamp, supplier and invoice identifiers, source channel, extraction record, validation evidence, and links to any review workbook or downstream posting. For a PDF/A-3 invoice, preserve the container with its embedded XML rather than retaining only an extracted copy of the attachment.

The spreadsheet is not a substitute for the invoice artifact. It contains selected and transformed values, may repeat headers across line rows, and cannot preserve every signature, attachment, attribute, or rule input. Re-running a parser or verifier later requires the same source bytes, so rendering, OCR, normalization, or a manual correction must create a derived record rather than overwrite the original.

Where Saudi VAT record rules apply, Article 66 of the current VAT Implementing Regulations requires invoices, books, records, and accounting documents to be kept for at least six years from the end of the tax period to which they relate. Records concerning capital assets follow the Article 52 adjustment period plus five years from acquisition. ZATCA guidance summarizes those longer minimums as eleven years for movable capital assets and fifteen years for immovable capital assets.

Retention classification belongs to the tax or records owner, not the XML parser. The organization must also account for legal holds, sector requirements, contractual obligations, and any law applying to the entity that received or stores the invoice. These can extend the period beyond the VAT baseline.

FATOORAH compliant invoice archiving is therefore more than saving a visible PDF in a folder. It means preserving the authoritative received artifact, its provenance, the evidence produced by each validation layer, and the relationship between that source and every normalized output for the period that applies to the record.

Invoice Data Extraction

Extract data from invoices and financial documents to structured spreadsheets. 50 free pages every month — no credit card required.

Try It Free
Continue Reading

Related Articles

Explore adjacent guides and reference articles on this topic.

Saudi Arabia Zakat for Businesses: ZATCA Rates, Calculation & Filing

ZATCA business Zakat guide for Saudi Arabia: 2.5% rate, Zakat base calculation, 120-day filing deadline, and Saudi/GCC vs foreign ownership tax split.

Saudi Arabia Reverse Charge VAT: Non-Resident Supplier Guide

Guide to Saudi Arabia's reverse charge VAT for non-resident suppliers. Covers FATOORAH e-invoicing exclusion, Box 9 reporting, and documentation requirements.

Convert a PDF Table to Excel Without Scrambled Data

Convert PDF tables to Excel reliably. Choose the right method for native, scanned, or multi-page files, then verify every row before using the data.

Back to Articles & Analysis

Invoice Data Extraction

The AI-native automation platform for high-accuracy invoice extraction

Platform

  • Start Extraction
  • Home
  • Pricing
  • API
  • Python SDK
  • Node.js SDK

Solutions

  • Invoice to Excel
  • Invoice OCR Software
  • Bank Statement Converter
  • Receipt OCR
  • Utility Bill Extraction
  • Payroll Data Extraction
  • PDF Data Extraction

Resources

  • Articles
  • Contact

Trust & Security

  • Security
  • Subprocessors
  • AI Data Use

Legal

  • Terms of Service
  • Data Processing Addendum
  • Privacy Policy
  • Refund Policy
  • US State Privacy Rights
  • EEA/UK Privacy Rights
English
Sign inCreate account

© 2026 Invoice Data Extraction — DEH Technologies LLC

Secure by Design. Your data is never used for AI training.