What do you mean by XML? What are its Differences and similarities from HTML? Also explain the concept of Entities & Attributes in XML?

Subject: Internet Programming

Topic: Web Extensions and Web Services

Difficulty: Medium

1 Answer

eXtensible Markup Language (XML)

  • XML is developed by the World Wide Web Consortium (W3C), which is used as a format to store and transfer data over the Web.
  • XML is a markup language based on simple, platform-independent rules for processing and displaying textual information in a structured way.
  • XML was designed to carry data, not to display data.
  • An XML document can be converted into another format, such as HTML and PDF, to make it more readable.
  • XML has been used to implement the following various operations, like
    • Configuration information
    • Publishing
    • Electronic Data Interchange (EDI)
    • Voicemail system
    • Remote Method Invocation (RMI)
    • Object Serialization

Differences and similarities from HTML

Similarities between XML and HTML

  • Both are originated from SGML. [Standard Generalized Markup Language]
  • Tags are basic building blocks of both HTML and XML documents.
  • Both are markup languages of web.
  • Both XML and HTML markups are used for responses either Direct or by AJAX.
  • Both HTML and XML are used to carry information. HTML is the standard markup for the web for displaying and formatting the data whereas XML is used for data binding / handling.

Difference between XML and HTML

  • HTML focuses on how data looks whereas XML focuses on what data is.
  • HTML tags are predefined tags whereas XML tags are user defined tags.
  • HTML tags are not case insensitive whereas XML tags are sensitive.
  • In HTML not mandatory to close tag whereas in XML it is mandatory to close tag.
  • HTML is presentation language whereas XML is neither programming nor presentational language.

Entities & Attributes in XML

Entities in XML

  • Some characters have a special meaning in XML. For example, the less than sign (<) marks the beginning of a tag. And, of course, the greater than sign (>) marks the end of the tag.
  • When the XML processor parses the document, it looks for these characters to determine how to interpret the document.
  • Imagine you had the following text within an element: 10 < 5. When the XML processor encounters the <, it will assume it's the start of an opening tag.
  • In order to include characters such as < and & etc. you need to use their entity reference instead of the character itself.
  • Entity Syntax - Entity reference using the & character and close it using the ; character.

Attributes in XML

  • Attributes give the information about the elements. They can be specified only in the element start tag and their values are enclosed in either single or double quotes
  • Syntax: <tag attribute = “value” >description </tag>
  • XML attributes cannot contain multiple values, tree structures and also attributes are not easily expandable (for future changes).
  • Attribute values are difficult to test against the DTD and also difficult to maintain programmatically.
Please log in to add an answer.