Difference between XML and HTML
Key difference: XML stands for Extensible Markup Language. It is a specification developed by the W3C. It is a markup language designed especially for Web documents. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. HTML stands for HyperText Markup Language. It is a well known mark up language used to develop web pages. It has been around for a long time and is commonly used in webpage design.
XML stands for Extensible Markup Language. It is a specification developed by the W3C. It is a markup language designed especially for Web documents. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. It allows designers to create their own customized tags. It also enables the definition, transmission, validation, and interpretation of data between applications and organizations.
XML is a text-based data format with strong support via Unicode for languages. It emphasizes simplicity, generality, and usability over the Internet. It is also widely used for the representation of arbitrary data structures, especially in web services. Programmers often use APIs while processing XML data and schema systems to aid in the definition of XML-based languages.
The XML syntax has formed the basis for many document formats, such as RSS, Atom, SOAP, and XHTML. In fact, XML-based formats have become the default for many office-productivity tools, including Microsoft Office, OpenOffice.org and LibreOffice, and Apple's iWork.
HTML stands for HyperText Markup Language. It is a well known mark up language used to develop web pages. It has been around for a long time and is commonly used in webpage design. XML or Extensible Markup Language defines a set of rules for encoding documents in a format that can be read by both, human and computer.
HTML is written using HTML elements, which consist of tags, primarily and opening tag and a closing tag. The data between these tags is usually the content. The main objective of HTML is to allow web browsers to interpret and display the content written between the tags. The tags are designed to describe the page content. HTML comes with predefined tags. They allow one to insert images, text, videos, forms and other pieces of content together into a cohesive webpage.
Some differences between XML and HTML:
- HTML was designed to display data with focus on how data looks, while XML was designed to be a software and hardware independent tool used to transport and store data, with focus on what data is.
- HTML is a markup language, while XML provides a framework for defining markup languages.
- HTML is a presentation language, while XML is neither a programming language nor a presentation language.
- HTML is case insensitive, while XML is case sensitive.
- HTML is used for designing a web-page to be rendered on the client side while XML is used basically to transport data between the application and the database.
- HTML has predefined tags, while XML has custom tags that can be invented or defined by the programmer.
- HTML does not require closing tags, while in XML, closing tags is mandatory for each tag.
- HTML does not preserve white space while XML does.
- HTML is about displaying data, while XML is about describing data.
- HTML is static, while XML is dynamic.
- In XML, data interchange is possible, while in HTML data interchange is not possible.
- In XML, attribute value must be enclosed within quotation marks, while in HTML attribute value can be present without quotation marks.
- In XML, if attribute is defined then it should have value and in HTML attribute value can be present without values.
- In XML, modularity can be provided by DTD, while in HTML there is no concept of DTD.
- XML used for presentation and HTML used for representation.
- XML is used as storage media, while in HTML there is no concept of Storage.
- HTML is error free language, while XML is not.
- In XML, parsing is used to execute the XML files but in HTML there is no facility of parsing.
- In HTML there is no data type, while in XML, some data types are defined.
- A HTML document may not be well formed document, whereas a XML document must be a well-formed document.
Image Courtesy: e-xmlmedia.com, teamtreehouse.com