Parse Fattura Xml
parse_fattura_xmlParse FatturaPA XML (FPR12/FPA12) into a structured Python dict to inspect or process invoices. Extracts header, body, line items, and payment data; returns errors on invalid XML.
Instructions
Parse a FatturaPA XML string into a structured Python dict.
Use this to inspect or process invoices received from counterparties, or to verify the output of generate_fattura_xml(). Accepts both FPR12 (B2B) and FPA12 (PA) formats. The result can be passed directly to export_to_json().
Extracts: versione, transmission data, seller/buyer identity and address, document type/date/number/causale, all DettaglioLinee, DatiRiepilogo, and DatiPagamento if present. Fields not found in the XML are returned as null.
On success returns {'versione': str, 'header': {...}, 'body': {...}}. On XML parse error returns {'error': 'XML parse error: '}. On missing lxml returns {'error': 'lxml is not installed...'}.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"xml_string": "<xml_string>"
},
"name": "parse_fattura_xml"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| xml_string | Yes | FatturaPA XML string to parse. Accepts both single-invoice (FPR12) and PA-addressed (FPA12) formats. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||