XML Basics

This post is a part of our How to begin with API Testing series. In this post, I will be covering XML Basics

What is XML:

So, what the heck is XML. XML is a markup language designed with focus on data sharing as opposed to HTML which is more focused on data presentation.




XML tags are not pre-defined like in HTML. In XML, tags and document structure are defined by its author. Usually, XML tags are self explanatory and describes the content between them.


For Eg:

    <<span class="mceItemHidden" data-mce-bogus="1"><span class="hiddenSpellError" pre="" data-mce-bogus="1">calllogs</span></span> count="2">
         <log number="01244528000" time="27 May 2017 11:46:38" date="1495865798367" dur="268" />
         <log number="123456789" time="28 May 2017 11:44:54" date="1495865694727" dur="0" />
    <<span class="hiddenSpellError" pre="" data-mce-bogus="1">sms</span> count="2">
         <log type = "received" number="8793472171" time="27 May 2017 01:21:58" date="1595665798367" />
         <log type = "sent" number="9693573142" time="28 May 2017 04:22:44" date="1395765694727" />

XML Syntax Rules:

  • It must contain one root element which is the parent of all other elements
  • All XML Elements Must Have a Closing Tag
  • XML Tags are Case Sensitive
  • XML Elements Must be Properly Nested
  • XML Attribute Values Must be Quoted

Entity References in XML:

Some characters cannot be used as content inside XML tags. So, we replace these characters with specific text (called Entity Reference) so as to parse these characters literally
There are 5 pre-defined entity references in XML:

&lt < less than
&gt > greater than
&amp; & ampersand
&apos; apostrophe
&quot quotation mark

Comments in XML:

The syntax for writing comments in XML is similar to that of HTML.

<!– This is a comment –>

Two dashes in the middle of a comment are not allowed.

XML does not truncate multiple white-spaces (HTML truncates multiple white-spaces to one single white-space)


Difference between HTML and XML:

Usage Display a web page Sharing data between the applications
Rules Interpreted even if it is malformed and invalid Need to be well-formed and valid before they can be interpreted
Tags Predefined Custom tags defined/created by its author
White Space Truncate white space Preserves white space
Case-Sensitive Yes No

I covered basics of XML in this post. For more detailed tutorial, please click here


2 thoughts on “XML Basics

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s