A partner system accepts XML while your Contact Form 7 workflow works with structured inquiry records. Choosing a parser means deciding how elements, attributes, namespaces and repeated answers become application data. Compare fast-xml-parser, xml2js, lxml, ElementTree and Nokogiri by the runtime your team maintains and the exact document contract, before choosing a familiar package name.

These are parsing libraries for a custom integration, not ready-made CF7 connectors. This documentation-based comparison covers core functionality and licensing checked November 20, 2026. We have not benchmarked the five products or tested them against your partner’s endpoint. An XML parser also does not provide lead routing, delivery retries or permission checks.
Five-library decision table
| Library | Runtime and useful fit | Core license | Main review point |
|---|---|---|---|
| fast-xml-parser | JavaScript object mapping and XML building | MIT | Explicit mapping and entity policy |
| xml2js | Node.js object conversion | MIT | Arrays and attribute conventions |
| lxml | Python trees, XPath and validation | BSD, dependencies separate | Parser configuration and native libraries |
| ElementTree | Python standard-library tree processing | Python/PSF terms | XPath subset and input trust |
| Nokogiri | Ruby XML trees and selectors | MIT, dependencies separate | Namespaces and parsing options |
None of these core licenses requires a recurring subscription fee for ordinary library use. Preserve required notices and review bundled dependencies. Hosting, maintenance, commercial support and any partner API charges remain separate costs. The table describes licensing, not a complete project budget or a recommendation to change your existing runtime.
fast-xml-parser
fast-xml-parser offers JavaScript XML parsing and building without native C or C++ bindings. Its documentation also describes ordered representations and configurable handling. That makes it a candidate when your custom receiver already uses JavaScript and needs to translate a partner document into a reviewed internal object.
Strength: one runtime can own the transformation and downstream API request. Keep a mapping layer between the parsed result and your inquiry schema. That layer can preserve a reference such as 000123 as text and require a repeated service element to become a list even when only one appears.
Limitation: a convenient object shape is not automatically your business contract. Review attributes, text values, element order and entity behavior for the version you deploy. Its name is not evidence that it is fastest for your workload. The core has an MIT license; integration code and operational ownership remain yours.
xml2js
xml2js converts XML into JavaScript objects in Node.js and includes a builder for the reverse direction. Its documented conventions represent attributes separately, and explicitArray controls whether child nodes consistently appear in arrays. These details matter when a lead can contain one interest today and several tomorrow.
Strength: a team maintaining an existing xml2js adapter can keep a consistent representation rather than rewriting it solely for a new partner. Inspect the adapter’s actual options, since historical defaults or an online example may differ from the deployed configuration. Build fixtures around the resulting objects, including a single repeated element.
Limitation: flattening or merging attributes can create collisions with child names, and disabling consistent arrays can make downstream types vary with cardinality. Treat serialization back to XML as a separate acceptance case; arbitrary transformations need not reproduce identical source bytes. The core license is MIT. It provides no native CF7 mapping or background delivery queue.
lxml
lxml is a Python XML toolkit with an ElementTree-style API and richer XML capabilities. Its documentation covers XPath, tree manipulation and validation facilities. It is worth considering when the receiving partner supplies a schema or when namespace-aware selections have outgrown a small hand-written traversal.
Strength: the integration can keep structured tree operations and deliberate validation in the same Python service. Separate well-formedness, schema acceptance and business validation in the error report. A document can be valid XML while still lacking the inquiry reference your workflow requires.
Limitation: native dependencies and parser options add deployment and configuration decisions. Review entity resolution, network access, recovery and document-size behavior for the installed version. Do not enable permissive options merely to make a malformed sample parse. lxml’s license information identifies BSD terms for lxml and separate licensing for its underlying libraries. Use a supported stable release deliberately rather than assuming the newest development documentation matches your environment.
ElementTree
Python’s ElementTree provides tree parsing, traversal and serialization in the standard library. For a small, trusted partner export with predictable structure, it may satisfy the adapter without adding another Python package. Namespaced element names still need explicit handling.
Strength: a modest reader can remain close to the application’s existing Python deployment. Its incremental processing facilities can also support a carefully designed file-processing workflow. That does not mean every parse automatically uses bounded memory; retain only the tree content your processing strategy actually needs.
Limitation: its supported XPath subset is not a replacement for every full XPath or schema-validation requirement. Read Python’s XML security guidance before handling unauthenticated input, and check the deployed Python and parser-library versions. Standard-library availability is not a guarantee that arbitrary hostile documents are safe. It is distributed under Python’s licensing terms, rather than the MIT terms used by several other libraries here.
Nokogiri
Nokogiri offers XML documents, tree operations and searching for Ruby applications. It fits a custom Ruby receiver or reporting job that already owns the lead handoff. Use its XML parser for an XML contract instead of relying on HTML recovery behavior.
Strength: the searching documentation covers XPath, CSS selectors and namespaces. This supports a readable mapping layer that selects the intended elements rather than splitting text around angle brackets. Keep namespace URIs in the contract: a prefix’s spelling is not the element’s complete identity.
Limitation: permissive parsing can conceal a sender’s malformed document unless your adapter inspects and handles errors deliberately. Review the configured parse options and dependencies for the package you deploy. Removing namespaces simply to make selectors shorter can merge meanings that the sender intended to distinguish. Nokogiri’s core license is MIT, while bundled components and optional commercial offerings require their own review.
Define one mapping exercise for every candidate
Use the same synthetic document family to compare suitability: one inquiry, several inquiries, one service element, several service elements, an empty optional element, a missing optional element and two namespace prefixes bound to the same URI. Include a leading-zero reference, non-ASCII name and an ampersand encoded as XML text.
Write the expected internal record before running a parser. Specify which fields remain strings, whether element order matters, and how absent versus empty values affect an update. Our payload-change guide covers compatibility across a handoff. Parsing success alone should never authorize a destructive CRM update.
For externally supplied documents, set an input-size budget and review the library’s documented treatment of entities, external resources and expansion. Reject or isolate unexpected content according to your receiving contract. Avoid logging complete messages or attachments when a scoped error reference is sufficient. These are acceptance criteria to implement and verify, not claims that every candidate passes them by default.
Choose according to the maintained workflow
Choose fast-xml-parser for an intentionally configured JavaScript object boundary, or xml2js when its established conventions match the Node.js adapter you maintain. Choose lxml when a Python workflow needs richer XML operations. Start with ElementTree for a suitably simple Python contract. Choose Nokogiri when Ruby is already responsible for the receiver. The strongest choice is the one whose mapping and error paths your team can explain and support.
This site publishes CF7 Analytics. Our free Svetlik Analytics for Contact Form 7 provides submission statistics in WordPress. It is not an XML transformation service. Confirm the partner record independently before treating an XML handoff as accepted, and keep that outcome separate from form submission and mail status.
