Documentation Index
Fetch the complete documentation index at: https://mintlify.com/eclipxe13/CfdiUtils/llms.txt
Use this file to discover all available pages before exploring further.
QuickReader is a lightweight, read-only view over a CFDI document designed for speed and convenience. It strips XML namespace prefixes and treats all element and attribute names as case-insensitive, so you can navigate a CFDI without memorising exact casing or namespace qualifiers. It is the right choice when you need to extract data quickly — for example, when exporting fields to a JSON structure or populating a PDF template.
QuickReader is a lossy transformation. Namespace information is discarded, and case distinctions are lost. It cannot read text nodes or XML comments. For full-fidelity access — or when you need to write or validate the document — use the Cfdi class and its NodeInterface tree instead.Get the QuickReader
CallgetQuickReader() on any Cfdi object. The returned QuickReader instance represents the root cfdi:Comprobante element.
Access Attributes
Use array notation (square brackets) to read attribute values. Attribute lookup is case-insensitive, soversion, Version, and vErSiOn all return the same value.
Calling offsetGet on a missing attribute returns an empty string — no exception is thrown. Use isset() to check whether an attribute is actually present.
Get All Attributes
CallgetAttributes() to retrieve the full attribute map as an associative array. Keys are stored with their original casing from the XML source.
Access Child Elements
Use property notation (arrow syntax) to navigate to a child element by name. The lookup is case-insensitive and returns the first matching child as a newQuickReader instance.
If no matching child exists, a QuickReader bearing the same name as the property you accessed is returned (with no attributes or children) — navigation never throws. Use isset() to test whether a child actually exists.
Access Multiple Children
To retrieve all children of a node, call theQuickReader object as if it were a function. The invocation returns an array of QuickReader instances.
Iterating Nested Children
Because$comprobante->conceptos() is interpreted by PHP as a method call on $comprobante, you must either assign the property to a variable first or wrap it in parentheses before invoking it.
Access Children by Name
Pass a name string to the invocation to retrieve only children whose name matches (case-insensitive).Node Name
In the rare case that you need the name of a node, cast it to string:Limitations
QuickReader is intentionally narrow in scope. Keep these constraints in mind:
- Lossy — XML namespace prefixes are stripped. Two elements from different namespaces but with the same local name are indistinguishable.
- Case-insensitive — original attribute and element casing is not preserved during lookup.
- Read-only — any attempt to set an attribute or child element throws a
\LogicException. The object is immutable by design. - No text nodes or comments — only XML elements and their attributes are imported; text content and XML comments are ignored.
When to Use QuickReader vs Cfdi
| Scenario | Recommended API |
|---|---|
| Export CFDI fields to JSON or a database | QuickReader |
| Populate a PDF or HTML template | QuickReader |
| Navigate with exact namespace and attribute names | Cfdi + NodeInterface |
| Validate a CFDI document | Cfdi + validator classes |
| Programmatic modification of the XML tree | Cfdi + NodeInterface |