XML
Rakesh Chaubey

Rakesh Chaubey @rakesh_chaubey_ac4fa25823

About: I love to solve problems

Joined:
May 26, 2025

XML

Publish Date: May 26
0 0

Today, JSON rules the world. But before that — and still in many large enterprises — XML was (and is) the silent workhorse. And in the logistics industry, you'll still find a lot of XML powering core systems like shipment tracking, ERP sync, customs data, and invoicing.

In this post, we’ll cover:

  • What XML is (with a real-world example)
  • Where it’s still used in logistics
  • Why some systems prefer it over JSON
  • Tips to handle XML well

🧠 What is XML?
XML (eXtensible Markup Language) is a text-based format used to store and exchange structured data. Think of it like HTML, but for data — and it’s both human-readable and machine-readable.
It uses opening and closing tags to define each field.

Here’s a simple logistics-related XML:

<Shipment>
  <ShipmentId>SHIP-98765</ShipmentId>
  <Origin>Mumbai</Origin>
  <Destination>Hyderabad</Destination>
  <Status>Out for Delivery</Status>
  <Items>
    <Item>
      <SKU>T-SHIRT</SKU>
      <Quantity>2</Quantity>
    </Item>
  </Items>
</Shipment>
Enter fullscreen mode Exit fullscreen mode

Pretty neat, right? This looks very similar to what you'd send or receive in a SOAP API or through an enterprise file-based integration.

🚚 Where XML is Still Used in Logistics
Even today, major Indian logistics companies and their backend systems — whether in supply chains, freight networks, or ERP systems — still exchange XML data regularly.

🔄 Here are a few real-life examples:

  • 🧾 Invoices and billing exchanged via EDI/XML
  • 📤 Shipment updates between warehouse management systems
  • ✈️ Customs declaration documents for international shipments
  • 🏦 Payment or reconciliation files from banks in XML format
  • 🔁 Legacy SOAP APIs (still common in big orgs)

Why XML is Still Preferred in Some Cases
Feature Why It Matters in Logistics
Strict structure Ensures every document follows a defined format (using XSD schemas)
Validation-ready You can catch errors before processing
Namespaces Helpful in large B2B integrations to avoid field conflicts
Mature ecosystem Works well with legacy tools like BizTalk, SAP, Oracle, etc.
SOAP Support Some logistics APIs still expose SOAP endpoints (which use XML)

Also, XML is verbose(verbose:XML uses a lot of repeating tags and extra characters (like angle brackets) to describe data.), but that’s not always a bad thing. When clarity and data reliability are more important than size (like in customs or compliance), XML shines.

verbose: XML uses a lot of repeating tags and extra characters (like angle brackets) to describe data. This leads to larger file sizes and more bandwidth usage

<Status>Delivered</Status>
<Location>Mumbai</Location>
Enter fullscreen mode Exit fullscreen mode

In XML, each piece of data requires:

  • An opening tag ()
  • A closing tag ()
  • And if nested, even more structure.

🔧 Best Practices When Working with XML
Use XSD for Validation: Is explained at bottom
Don’t accept XML blindly — validate it using an XML Schema Definition (XSD) to make sure it’s safe and structured properly.

Avoid Deep Nesting
Logistics data often involves nested items — keep your hierarchy simple to avoid parser issues.

Prefer Elements Over Attributes (Usually)

<Item>
  <SKU>T-SHIRT</SKU>
  <Quantity>2</Quantity>
</Item>
Enter fullscreen mode Exit fullscreen mode

This is more readable than packing everything into attributes.

Watch Your Encodings
Always declare your encoding at the top:

<?xml version="1.0" encoding="UTF-8"?>
Enter fullscreen mode Exit fullscreen mode

Convert XML to JSON for Modern Systems
If your .NET or Node.js service receives XML from a legacy vendor, use conversion libraries to bridge the gap with your JSON-based APIs.

🆚 JSON vs XML — Quick Thoughts
Feature JSON    XML
Readability Cleaner Verbose
Validation  Less strict (optional)  Strong with XSD
Data Format Lightweight Heavier
Tooling Modern APIs & UIs   Enterprise tools, SOAP
Use Case    Mobile, APIs, Kafka ERP, finance, SOAP systems
Enter fullscreen mode Exit fullscreen mode

In modern logistics platforms, we often find both JSON and XML living side by side.

Logistics tech in India — from Delhivery, BlueDart, DTDC, to Indian Railways freight, and even eInvoice systems under GST — often requires XML formats for backend integration.

So even if you're building the latest microservice in .NET 8 or using Kafka, don’t be surprised if you have to consume an XML feed from a legacy SAP system.

🧵 Wrapping Up
If you're a backend or integration engineer working in logistics, XML isn't going anywhere just yet. It might not be trendy, but it’s stable, secure, and well-suited for B2B and enterprise workflows.

When you receive XML data — say from a courier partner, ERP system, or customs gateway — how do you know it’s correct? That’s where XSD comes in.

✅ XSD stands for XML Schema Definition.
It acts like a contract that defines:

  • What elements and attributes are allowed
  • Data types (string, date, int, etc.)
  • Required vs optional fields
  • Structure, nesting, and cardinality

📦 Example: Shipment XML
XML file:

<Shipment>
  <ShipmentId>SHIP-12345</ShipmentId>
  <Status>Dispatched</Status>
  <Weight>12.5</Weight>
</Shipment>

Enter fullscreen mode Exit fullscreen mode

Corresponding XSD:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Shipment">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="ShipmentId" type="xs:string"/>
        <xs:element name="Status" type="xs:string"/>
        <xs:element name="Weight" type="xs:decimal"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

Enter fullscreen mode Exit fullscreen mode

This ensures:

  • ShipmentId is a string ✅
  • Weight must be a decimal ✅
  • No extra or missing tags allowed ❌

🛠 Why Use XSD in Logistics?

  • ✅ Validates XML structure before processing
  • 🚫 Prevents corrupt or incomplete shipment/invoice data
  • 🔐 Adds security by rejecting unexpected inputs
  • 🏗 Helps generate documentation and UI forms

In .NET, Java, or Python, you can easily load the XSD and validate incoming XML against it using built-in libraries.

🔧 .NET Example (C#):

var schemaSet = new XmlSchemaSet();
schemaSet.Add("", "Shipment.xsd");

var settings = new XmlReaderSettings();
settings.Schemas = schemaSet;
settings.ValidationType = ValidationType.Schema;
settings.ValidationEventHandler += (s, e) =>
{
    Console.WriteLine("Validation Error: " + e.Message);
};

using var reader = XmlReader.Create("Shipment.xml", settings);
while (reader.Read()) { }
Enter fullscreen mode Exit fullscreen mode

🧵 Bottom Line:
Always ask your partners for an XSD when consuming XML.
It’s the safety net that saves you from bad data and runtime bugs — especially in critical logistics pipelines.

Comments 0 total

    Add comment