DEV Community

Cover image for Is XML Dead?
Dalbir Singh
Dalbir Singh

Posted on

2

Is XML Dead?

Today I was asked to provide technical consultation for a customer involving the generation of an XML document.

These days we developers play with JSON, but it is worth noting XML played some influence with JSON’s global adoption. You’ll often hear a lot talk about data models, sequences, markup and so forth in the JSON community – lessons that were learned from putting together XML standards.

<?xml version="1.0"?>
<catalog>
   <book id="bk101">
      <author>Gambardella, Matthew</author>
      <title>XML Developer's Guide</title>
      <genre>Computer</genre>
   </book>
   <book id="bk102">
      <author>Ralls, Kim</author>
      <title>Midnight Rain</title>
      <genre>Fantasy</genre>
      <price>5.95</price>
   </book>
</catalog>
Enter fullscreen mode Exit fullscreen mode

It’s been a while since I authored an XML document – I was reminded how the data structures are easier to read and understand. That’s not to say JSON isn’t readable, its just that with XML and it’s SGML derivatives the model is easier to comprehend, initially at least.

When I started thinking about how to parse XML documents again, It was then I was reminded why JSON is loved. While XML presents the data in an immediately readable format, JSON presents the data in an easily digestible format for your application code. No need, for complex XPath queries, just bind it to your internal model and your done!

If JSON is the preferred choice for data transfer within applications, does XML have anything left to offer?

Yes – documents…

XSLT

XSLT (eXtensible Stylesheet Language Transformations) is a language for transforming XML documents into other XML documents, or other formats such as HTML for web pages, plain text or XSL Formatting Objects, which may subsequently be converted to other formats, such as PDF, PostScript and PNG.

Alt Text

Example of XML/XSLT: In the image above you can see an example of XML and XSLT working together. The XSLT file uses XPath queries to lift information out of the XML document and render the content using templates. The output is shown below.

XML still works best for documents. Documents by their nature have a form of structure that is represented better through XML.

Combine XML with XSLT and you’re able to perform impressive transformations with nothing more than .xml and .xsl files.

So, Is XML Dead?

Not yet – XML still has its place for document-based structures. Also many financial institutions rely heavily on XML based formats for transferring information between enterprise systems that were built in the 2000s.

It’s well known financial enterprises such as Banks are reluctant to ‘upgrade’ their systems unless they really need to. So XML may not be the new kid on the block, and relegated to more mundane infrastructure but it’s still alive and kicking. 🤓

What about you? - Do you still use XML day to day?

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (1)

Collapse
 
yokotobe profile image
yokotobe

For all system I built, I chose JSON. But still need to consume XML from another.

The best way to debug slow web pages cover image

The best way to debug slow web pages

Tools like Page Speed Insights and Google Lighthouse are great for providing advice for front end performance issues. But what these tools can’t do, is evaluate performance across your entire stack of distributed services and applications.

Watch video

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay