Cahpter 9:XML Display

Displaying XML — written as if I’m your patient teacher explaining step by step how XML is actually shown / presented / viewed / displayed in different real-life situations.

We will cover many different ways people “display” XML, why each method exists, what it looks like to the user, and realistic examples for each approach.

1. Raw XML – The Most Basic Way (Text Editor / Source View)

This is what developers and people who work with XML see most often.

Tools used:

  • Notepad++, VS Code, Sublime Text, Vim
  • Browser “View Page Source”
  • Any plain text editor

Example (very simple student record):

XML

How it looks:

  • Just plain text
  • Usually syntax-highlighted in modern editors (tags = blue/purple, attributes = green/red, text = black/white)
  • Indentation is very important for readability

When people use this:

  • Debugging
  • Writing / editing XML
  • Checking structure
  • Copy-pasting into APIs / configurations

2. Pretty-Printed / Formatted XML (Indented & Readable)

Most real XML files are written with proper indentation so humans can read them easily.

Before pretty-printing (ugly one-line version):

XML

After pretty-printing (what you usually see):

XML

Tools that do this automatically:

  • VS Code (Ctrl+Shift+I or right-click → Format Document)
  • Online formatters (xmlformatter.org, freeformatter.com, etc.)
  • XML editors (Oxygen XML, XMLSpy, Notepad++ with XML Tools plugin)
  • xmllint –format file.xml (Linux/Mac)

Most developers prefer this view — it is the standard way to read and understand XML.

3. Tree View / Outline View (Hierarchical / Expandable)

Many XML editors show XML as a collapsible tree — very useful when documents are large.

How it looks (text representation of tree view):

text

Where you see this:

  • Oxygen XML Editor
  • XMLSpy
  • Visual Studio (XML editor)
  • Eclipse XML perspective
  • Online tools like codebeautify.org/xmlviewer
  • Some API testing tools (Postman XML response view)

Best for:

  • Large documents (hundreds or thousands of lines)
  • Quickly finding a particular element
  • Understanding deep nesting

4. Browser Display (Default Behavior)

When you open an .xml file directly in a modern browser (Chrome, Firefox, Edge):

What you usually see:

  • Raw XML text
  • Syntax-highlighted (tags blue, attributes purple, etc.)
  • Indented automatically (pretty-printed)
  • No collapsing — just long scrollable text

Example (Firefox does this very nicely):

  • Tags in blue
  • Attribute names in red
  • Attribute values in purple
  • Text content in black
  • XML declaration in gray

Very important note:

If the XML file has a stylesheet reference (<?xml-stylesheet …?>), the browser tries to render it nicely instead of showing raw XML.

Example:

XML

→ Browser shows formatted invoice (like HTML), not raw XML.

5. Styled / Transformed XML (XSLT → HTML or PDF)

This is how XML is displayed to normal users (customers, managers, government portals, etc.).

Common flow:

  1. XML data exists
  2. XSLT stylesheet transforms it
  3. Result → nice HTML page, PDF, Word-like document

Very common real example – Indian GST e-Invoice display:

XML

Displayed as (what user sees in browser / PDF):

text

Tools / technologies used:

  • XSLT 1.0 / 2.0 / 3.0
  • XSL-FO → PDF (Apache FOP, Antenna House, etc.)
  • Modern: XML → JSON → React/Vue/Angular frontend

6. Grid / Table View (Excel-like)

Some tools show XML as a table / spreadsheet:

  • Oxygen XML Grid view
  • XMLSpy Grid Editor
  • Excel (with XML Maps)
  • Some database tools

How it looks:

orderId customer.name items[1].sku items[1].name totalAmount
ORD-20250704-3192 Samarth Jain HDMI-2M HDMI Cable 2 meter 349.00
ORD-20250704-3193 Priya Sharma TS-BLK-M Black T-Shirt M 998.00

Used for:

  • Data analysis
  • Quick editing of repeating structures
  • Importing/exporting to Excel

Quick Summary – Ways to Display XML (from most technical to most user-friendly)

# Display method Who uses it Looks like Best for
1 Raw text Developers Plain text, maybe highlighted Editing, debugging
2 Pretty-printed Everyone who reads XML Indented, colored tags Reading & understanding
3 Tree / Outline view Developers & analysts Collapsible hierarchy Large documents, navigation
4 Browser default Quick checking Highlighted raw XML Fast preview
5 XSLT → HTML / PDF End users, customers, portals Nice invoice, report, form Official display, printing
6 Grid / Table view Business users, analysts Excel-like table Repeating data, analysis

Would you like to go deeper into any of these display methods?

  • How to pretty-print XML yourself (tools & shortcuts)
  • Creating a simple XSLT to turn XML into nice HTML
  • Differences between browser rendering of XML vs HTML
  • How real portals (GST, banking, ERP) display XML data to users
  • Tools comparison: Oxygen vs XMLSpy vs VS Code for displaying XML
  • Displaying XML inside web applications (modern JavaScript way)

Tell me which direction interests you most right now! 😊

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *