Articles on: Frequently Asked Questions (FAQ)

How do I configure XML parent and variant nodes?

Stock Sync now supports JMESPath expressions in combination with Liquid templating, giving you powerful tools to transform and extract data from both JSON and XML feeds.

This article explains how to configure Parent Node and Variant Node settings in Stock Sync to handle structured data, especially useful for feeds where variant data is nested or stored separately.

📘 What Are JMESPath and Liquid?



JMESPath is a query language for JSON, allowing you to filter, project, and manipulate feed data. Learn more: jmespath.org

Liquid is a templating language used to reference dynamic values (like Shopify's {{product.id}}). Learn more: Shopify Liquid Reference

To check the mapping in Step 2: Matching Column for the XML node, you can refer to here.

Before exploring JMESPath examples, let's cover a few essential concepts. While there's much to learn, I'll simplify it here by focusing on key aspects. For more in-depth information, refer to external resources.

1. Basic Expressions


To select a specific expression value from "b" in a JSON object, use the following example:


To extract a nested value from "value" in a JSON object:


There is an index expression as well which is known as to select a specific element in a list. It should look similar to array access in common programming languages. Indexing is 0 based.


Index expression to select a specific element from a list containing two elements separated by another element.

2. Slicing


Slicing extracts a specific portion of a sequence by specifying a start and end index. For example, slicing from index 0 to 3 retrieves the first three elements.


If the start or stop value is omitted, it defaults to the beginning or end of the array respectively, as shown in the image with the ending index which only gets 5 elements.

To get values with even numbers only, use this method.


Example 1: Standard XML Feed with Nested Variants




{
  "products": [
    {
      "title": "T-Shirt",
      "stock_sync_variant_title": "Apparel",
      "variants": [
        {
          "title": "red-small-cotton",
          "quantity": 3
        },
        {
          "title": "blue-medium-cotton",
          "quantity": 4},
      ]
    },
    {
      "title": "Jeans",
      "stock_sync_variant_title": "Apparel",
      "variants": [
        {
          "title": "red-small-cotton",
          "quantity": 3
        },
        {
          "title": "blue-medium-cotton",
          "quantity": 4}, 
      ]
    },
    {
      "title": "Sweater",
      "stock_sync_variant_title": "Apparel",
      "variants": [
        {
          "title": "red-small-cotton",
          "quantity": 3
        },
        {
          "title": "blue-medium-cotton",
          "quantity": 4},
      ]
    }
  ]
}


To retrieve all product details, use products as the parent node.


To specify only the end index, use products[:2] as the parent node.


To specify only the start index, use products[1:] as the parent node.

Example 2: XML Products Data



{
  "root": {
    "products": [
      {
        "currency": "EUR"
      },
      {
        "product": {
          "url": "https://zuja.lt/daugkartinis-burbulinis-modelinas",
          "id": "1",
          "supplier_id": "1",
          "description": [
            {
              "language_id": "1",
              "title": "Daugkartinis burbulinis modelinas",
              "description": "<p><strong>Daugkartinis burbulinis modelinas </strong>- modeliuoji, modeliuoji ir niekad nesukietėja.</p><ol><li>Minkštas ir lengvas modelinas su stambiais polistirolo karoliukais.</li></p>",
              "short_description": ""
            },
            {
              "language_id": "2",
              "title": "Reusable Soft Foam",
              "description": "<p><strong>Reusable Soft Foam </strong>- shape it over and over again!</p><ul><li>Soft and lightweight modelling clay with polystyrene beads.</li><li>Does not dry up and can be used again and again </li>",
              "short_description": ""
            }
          ],
          "code": "78060",
          "sku": "78060",
          "barcode": "5712854177474",
          "price": "7.14",
          "price_without_vat": "5.9000",
          "price_old": "9.99",
          "price_old_without_vat": "8.2600",
          "note1": "0",
          "note2": "0",
          "total_quantity": "126",
          "minimum_quantity": "1",
          "product_categories": {
            "category_id": [
              "41",
              "42",
              "148",
              "151",
              "204"
            ]
          },
          "delivery_text": "1-2 d.d",
          "manufacturer_id": "31",
          "images": {
            "image": "https://zuja.lt/image/data/products/1/1/daugkartinis-burbulinis-modelinas_1.jpg"
          },
          "weight": {
            "prefix": "=",
            "measures": "kg.",
            "weight": "0"
          },
          "sizes": {
            "measures": "m.",
            "width": "0",
            "height": "0",
            "length": "0"
          },
          "status": "1",

    "variants" :
            {
              "type": "select"
            },
              "variant": [
                {
                  "title": "RaidÄ—"
                },
                {
                  "id": "5"
                },
                {
                  "title": "RaidÄ—"
                },
                {
                  "price": "0.0000"
                },
                {
                  "price_prefix": "+"
                },
                {
                  "value_title": "A"
                },
                {
                  "quantity": "16"
                },
                {
                  "code": "BN82232"
                },
                {
                  "barcode": "4019359822320"
                },
                {
                  "weight": {
                    "prefix": "+",
                    "measures": "kg.",
                    "weight": "0.00000000"
                  }
                }
              ]
            }
      }
    ]
  }
}


To retrieve the products list, you need to set the parent node as this root.products[1:].product or root.products[*].product


Example 3: Complex XML with Variants



{
  "variant": [
    {
      "title": "RaidÄ—"
    },
    {
      "id": "5"
    },
    {
      "title": "RaidÄ—"
    },
    {
      "price": "0.0000"
    },
    {
      "price_prefix": "+"
    },
    {
      "value_title": "A"
    },
    {
      "quantity": "16"
    },
    {
      "code": "BN82232"
    },
    {
      "barcode": "4019359822320"
    },
    {
      "weight": {
        "prefix": "+",
        "measures": "kg.",
        "weight": "0.00000000"
      }
    }
  ]
}


To get the variant list and specific variant values, set the variant node as variant.{title: [].title | [0], id: [].id | [0], price: [].price | [0], quantity: [].quantity | [0], weight: [].weight | [0] } can refer to the image below. If you only define the variant at the variant node level, all sections will be included.

If you didn't specify the variant node, you need to map it as this (e.g., {{data.variant[3]}} for the price). By specifying the variant node, you only need to map as a price

Updated on: 20/06/2025

Was this article helpful?

Share your feedback

Cancel

Thank you!