The Wayback Machine - https://web.archive.org/web/20240810223620/https://www.geeksforgeeks.org/sgml-vs-xml/
Open In App

SGML vs. XML

Last Updated : 23 Nov, 2023
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

SGML, created in 1969 and defined by ISO in 1986, is a key development in the representation of structured data. It opened the way for more modern languages like XML, which only started to gain popularity in 1996 and was given W3C recommendation status in 1998. While SGML provided the foundation, XML added advances addressing contemporary data storage and exchange demands. The comparison that follows will examine these two markup languages’ finer points and provide an understanding of their distinctive advantages and disadvantages.

Standard Generalized Markup Language (SGML):

  • The Standard Generalized Markup Language (SGML), often known as the “Generalized Markup Language,” is a comprehensive and incredibly versatile markup language intended for specifying the organization and display of texts.
  • It provides the structural underpinnings for many other markup languages, such as XML and HTML (eXtensible Markup Language). Custom document types and the rules governing their organization and presentation may be created using SGML.
  • The foundation of SGML is made up of Document Type Definitions (DTDs), which offer the structural and content models for each document component. DTDs’ extensive structure for defining relationships and constraints between components makes them incredibly adaptable for a wide range of applications.

Example:

HTML




<EMAIL>
    <RECEIVER>
        <PERSON>
            <FIRSTNAME>GeeksForGeeks</FIRSTNAME>
        </PERSON>
    </RECEIVER>
 
    <BODY>
        <h1>The Learning Portal.</h1>
        <p>
              This is a sample paragraph for
              demonstrating SGML Example.
          </p>
    </BODY>
</EMAIL>


Output:

Screenshot-(636)

SGML Example Output

Extensible Markup Language (XML):

  • The markup language known as XML, also known as the extensible markup language, evolved from SGML and is more user-friendly. Since XML is made to structure and encode data in a human-readable format, it may be used for a variety of purposes, including data exchange and configuration files.
  • Documents in XML are arranged using elements included in tags. Data is included within these tags, which establish the document’s hierarchical structure. An optional XML declaration that identifies the version and encoding is included at the start of every XML document.

Example:

HTML




<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html>
<to>To: All Learners</to><br>
<from>From: GeeksForGeeks</from><br>
<heading>Reminder</heading>
 
<body>
    <p>Don't forget to follow:</p>
    <h1>GeeksForGeeks</h1>
    <p>A Computer Science Portal For Geeks</p>
</body>
 
</html>


Output:

Screenshot-(637)

XML Example Output

SGML vs. XML

SGML

XML

Standard Generalized Markup Language (SGML)

Extensible Markup Language (XML) 

Created in 1980s

Created in 1990s

Used for data exchange and storage

Used for representing structured information

More complex and flexible markup language.

Simplified and more specific.

It allows high degree of customization

It is more specific in nature.

Allows creatiion of new tags

It has predefined rules for tags and elements.

Used in various industries like publishing, aerospace, and document management.

Used in web for representing and exchanging structured data.

Conclusion: Although both SGML and XML are useful tools for structuring and organizing data, their functions and traits are different. Modern applications favor using XML over SGML for data exchange and storage because it is more organized and standardized whereas SGML is more extendable and flexible. When deciding which of the two markup languages to use for certain projects or applications, it is crucial to comprehend these distinctions.



Similar Reads

What is SGML ?
In this article, we are going to learn about SGML.SGML stands for Standard generalized markup language is a Standard generalized markup language that makes use of a superset of extensively used markup languages like HTML and XML. It is used for marking up files and has the gain of now no longer depending on a particular application. It is basically
2 min read
Difference Between HTML and SGML
Most of us are familiar with HTML due to its connection to the World Wide Web. It drives the internet, allowing us to build and use websites, share material, and communicate with online services. HTML is only one branch of a much broader tree called SGML, which serves as the basis for several markup languages used in fields outside of the web. In t
5 min read
Difference Between text/xml and application/xml for Webservice Response
application/xmlThis is the recommended media type for XML data according to the IETF specifications [RFC 7303]. It signifies that the XML content might not be human-readable and could potentially contain processing instructions or other non-human-consumable elements. Syntax:Content-Type: application/xmlThis example demonstrates a web service respon
2 min read
Web technologies | HTML and XML | Question 1
Which of the following is an advantage of putting presentation information in a separate CSS file rather than in HTML itself? (A) The content becomes easy to manage (B) Becomes easy to make site for different devices like mobile by making separate CSS files (C) CSS Files are generally cached and therefore decrease server load and network traffic. (
1 min read
Displaying XML Using CSS
XML stands for Extensible Markup Language. It is a dynamic markup language. It is used to transform data from one form to another form. An XML file can be displayed using two ways. These are as follows :- Cascading Style Sheet Extensible Stylesheet Language Transformation Displaying XML file using CSS : CSS can be used to display the contents of th
4 min read
Displaying XML Using XSLT
XSLT stands for Extensible Stylesheet Language Transformation. XSLT is used to transform XML document from one form to another form. XSLT uses Xpath to perform matching of nodes to perform these transformation . The result of applying XSLT to XML document could be an another XML document, HTML, text or any another document from technology perspecti
3 min read
XML | Syntax
Prerequisite: XML | Basics In this article, we are going to discuss XML syntax rule which is used while writing an XML document or an XML application. It is a very simple and straight forward to learn and code. Below is a complete XML document to discuss each component in detail. C/C++ Code &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=
3 min read
XML | Tags
XML tags are the important features of XML document. It is similar to HTML but XML is more flexible then HTML. It allows to create new tags (user defined tags). The first element of XML document is called root element. The simple XML document contain opening tag and closing tag. The XML tags are case sensitive i.e. &lt;root&gt; and &lt;Root&gt; bot
2 min read
XML | Elements
The XML elements are the basic building block of the XML document. It is used as a container to store text elements, attributes, media objects etc. Every XML documents contain at least one element whose scopes are delimited by start and end tags or in case of empty elements it is delimited by an empty tag. Syntax: &lt;element-name attributes&gt; Co
2 min read
XML | Attributes
Prerequisite: XML | BasicsThe XML attribute is a part of an XML element. The addition of attribute in XML element gives more precise properties of the element i.e, it enhances the properties of the XML element.Syntax: &lt;element_name attribute1 attribute2 ... &gt; Contents... &lt;/element_name&gt; In the above syntax element_name is the name of an
3 min read
three90RightbarBannerImg