Open In App

SGML vs. XML

Last Updated : 23 Nov, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

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.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads