Destinations

Custom XML Implementation: Technical Documentation and Field Mapping

Complete guide to building, validating, and deploying custom XML product feeds with proper schema configuration, namespace handling, and error management.

8 min read 2 views Updated 4 Jul 2026

No results found

Try different keywords or browse all help articles.

    Introduction

    Custom XML feeds allow merchants to structure product data in formats tailored to their specific distribution channels, internal systems, or legacy infrastructure. Unlike pre-built integrations, custom XML implementation requires careful attention to schema design, namespace configuration, and validation rules. This guide covers the technical foundations needed to build XML feeds that parse correctly, pass schema validation, and integrate reliably with downstream systems.

    Whether you are migrating from another format, supporting a proprietary channel, or building feeds for multiple destinations simultaneously, proper XML structure prevents parsing failures, approval delays, and data loss in transmission.

    XML Schema Design and Document Type Definitions

    The foundation of any custom XML feed is a well-defined schema. A schema acts as a contract between your feed and the system consuming it, specifying which elements are required, which are optional, what data types they accept, and how they relate to one another.

    Two primary approaches exist for schema definition: Document Type Definitions (DTD) and XML Schema Definition (XSD). DTDs are simpler and older, using a compact syntax that declares elements and their allowed content. XSD files are more powerful and verbose, offering fine-grained control over data types, constraints, and nested structures.

    When designing your schema, establish clear rules:

    • Define the root element that wraps all product records.
    • Declare which fields are mandatory (products cannot be listed without them).
    • Specify data types for each field: string, integer, decimal, boolean, or date.
    • Set length constraints where applicable (product titles often have maximum character limits).
    • Establish enumerated values for fields with fixed options (e.g., availability states: 'in stock', 'out of stock', 'pre-order').
    • Document default values for optional fields that receivers may interpret as missing.

    For example, a basic product element might require id, title, price, and availability, while description, image_link, and brand are optional. Numeric fields like price should reject alphabetic input, and boolean fields should accept only true/false values.

    Storing your schema as a separate XSD file allows validation tools to check your feed before submission. Many XML parsers can load an external schema and report violations before the feed reaches a distribution channel, saving time and preventing rejections.

    XML Namespaces Configuration

    Namespaces prevent element name collisions when combining data from multiple sources or using third-party vocabularies. A namespace is declared using the xmlns attribute and acts as a prefix to element names.

    For instance, if your feed mixes product data with pricing information from a different system, you might declare:

    <feed xmlns:product="http://example.com/product"
          xmlns:pricing="http://example.com/pricing">
      <product:item>
        <product:title>Widget</product:title>
        <pricing:price currency="GBP">19.99</pricing:price>
      </product:item>
    </feed>
    

    Namespace URIs do not need to resolve to actual web pages; they are unique identifiers. The prefix (product, pricing) is what appears in your XML tags.

    When configuring namespaces:

    • Use consistent prefixes throughout the feed to avoid confusion.
    • Declare namespaces at the root element level so they apply to all descendants.
    • Avoid deep nesting of namespace declarations; it complicates parsing.
    • If using standard vocabularies (like Google's product schema), use their official namespace URIs.
    • Document your namespace choices so downstream consumers understand the structure.

    Parsers must be configured to recognise and handle namespace-prefixed elements correctly. If your feed uses namespaces but the parser expects unprefixed elements, it will fail to locate the data.

    XML Parsing Best Practices

    XML parsing is the process of reading an XML file and converting it into a data structure a program can work with. Different parsing approaches have different strengths.

    DOM (Document Object Model) parsing loads the entire XML file into memory as a tree structure. This approach is convenient for small to medium feeds because you can navigate elements freely and modify them before processing. However, DOM parsing consumes significant memory for large feeds (tens of thousands of products), and it is slower than streaming approaches.

    SAX (Simple API for XML) parsing reads the file sequentially, triggering events as it encounters opening tags, closing tags, and text content. SAX is memory-efficient and fast, making it ideal for large feeds. The trade-off is that you cannot look ahead or navigate backwards; you must process data as it arrives.

    When building or consuming a custom XML feed:

    • Choose DOM for feeds under 10,000 products or when you need flexible data manipulation.
    • Choose SAX for feeds over 10,000 products or when memory is constrained.
    • Ensure your parser is configured to handle the character encoding declared in the XML declaration (usually UTF-8).
    • Use a streaming parser if the feed is generated on-the-fly from a database.
    • Test parsing with real data before deploying to production.

    Common parsing errors include mismatched opening and closing tags, unescaped special characters (like ampersands in URLs), and incorrect encoding declarations. A parser will halt on these errors, preventing the entire feed from being processed.

    Schema Compliance Checking and XML Error Handling

    Validating your XML feed against its schema before submission catches errors early and prevents rejections by distribution channels.

    Validation checks:

    • Whether all required elements are present in every product record.
    • Whether element values match their declared data types (e.g., a price field contains a number, not text).
    • Whether values respect length constraints and enumerated choices.
    • Whether the XML is well-formed (all tags properly opened and closed, no overlapping elements).
    • Whether special characters are properly escaped.

    Tools for validation include command-line utilities (xmllint, xsd), online validators, and programming libraries (libxml2, lxml in Python, javax.xml in Java). Most feed management platforms include built-in validation that reports errors with line numbers, making debugging straightforward.

    Error handling strategies:

    • Log all validation errors with the product ID and field name so you can locate and fix the source.
    • Implement a quarantine process: hold products with validation errors out of the feed until they are corrected.
    • Set up alerts if the error rate exceeds a threshold (e.g., more than 2% of products fail validation).
    • Provide fallback values for optional fields if data is missing or invalid.
    • Document which errors are fatal (the entire feed is rejected) versus non-fatal (individual products are skipped).

    Regular validation runs, ideally after every feed generation, prevent bad data from reaching downstream systems.

    XML Data Mapping and Structured Document Formats

    Data mapping defines how fields in your source system correspond to elements in your XML feed. A product database might store a field called 'product_sku', but your XML schema expects 'sku'. Mapping ensures data flows to the correct location.

    Create a mapping document that lists:

    • Source field name (from your database or inventory system).
    • Target XML element name.
    • Data type conversion rules (e.g., convert a decimal price to a string).
    • Transformation logic (e.g., concatenate first and last name into a single author field).
    • Default values if the source field is empty.
    • Validation rules specific to that field.

    For example:

    Source Field XML Element Type Transformation Notes
    product_id id string None Required; must be unique
    product_name title string Trim whitespace Required; max 200 characters
    cost_price price decimal Round to 2 places Required; currency in separate attribute
    in_stock availability string Map true to 'in stock', false to 'out of stock' Required; enumerated values only
    description_html description string Strip HTML tags, escape ampersands Optional; max 5000 characters
    product_image image_link string Validate URL format Optional; must be HTTPS

    Structured document formats like XML benefit from clear mapping because they enforce strict hierarchies. Unlike flat CSV files where column order is flexible, XML requires elements to appear in the order defined by the schema. Mapping documentation prevents mistakes during feed generation.

    Practical Guidance for Merchants

    When implementing a custom XML feed:

    1. Start with a small batch of products (50 to 100) to test schema design and validation before scaling to your full catalogue.

    2. Use a feed management tool or custom script to automate feed generation from your source system. Manual XML editing is error-prone and does not scale.

    3. Generate feeds on a regular schedule (daily, hourly, or in real-time depending on your update frequency) and store versioned copies so you can roll back if needed.

    4. Run validation after each generation and log results. Set up monitoring to alert you if validation fails.

    5. Test feed parsing with the actual system that will consume it. Provide the feed to the downstream platform in a staging environment first.

    6. Document your schema, namespace configuration, and data mapping in a format accessible to your team and any third-party integrators.

    7. Monitor feed consumption on the receiving end. Check that products are appearing correctly, that prices and availability are updating, and that no data is being truncated or misinterpreted.

    8. Review error logs regularly. If certain fields consistently fail validation, investigate the source data and adjust your transformation logic.

    Summary

    Custom XML feeds provide flexibility for merchants working with proprietary systems or multiple distribution channels. Success depends on careful schema design, proper namespace configuration, reliable parsing, strict validation, and clear data mapping. By following XML parsing best practices, defining schemas precisely, and validating before deployment, you ensure feeds are accepted by downstream systems, data arrives intact, and products are listed correctly. Regular monitoring and error handling keep feeds reliable over time as your catalogue and systems evolve.