DIFFERENCE BETWEEN HTML AND XML

If you have any queries please leave a message here
Your Message
×


XML is a markup language whose primary purpose is to transport and store data. It is a language that can be used to develop new languages and define other languages. It does not have a predefined set of tags, and allows the developer to customize tags.
HTML is a markup language that is used to design web pages. It is written in predefined tag elements. Its primary purpose is to display data with focus on how the data looks.

HyperText Markup Language (HTML) 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.
Extensible Markup Language (XML) defines a set of rules for encoding documents in a format that can be read by both, human and computer.

HTML
XML
HTML is used to display data and focuses on how data looks.XML is a software and hardware independent tool used to transport and store data. It focuses on what data is.
HTML is a markup language itself.XML provides a framework to define markup languages.
HTML is not case sensitive.XML is case sensitive.
HTML is a presentation language.XML is neither a presentation language nor a programming language.
HTML has its own predefined tags.You can define tags according to your need.
In HTML, it is not necessary to use a closing tag.XML makes it mandatory to use a closing tag.
HTML is static because it is used to display data.XML is dynamic because it is used to transport data.
HTML does not preserve whitespaces.XML preserve whitespaces.




DOCUMENT TYPE DECLARATION (DTD)

A DTD is a Document Type Definition.
A DTD defines the structure and the legal elements and attributes of an XML document.
The purpose of a DTD is to define the structure of an XML document. It defines the structure with a list of legal elements:


<!DOCTYPE Person
[
<!ELEMENT Person (FirstName, MiddleName?, LastName)>
<!ELEMENT FirstName (#PCDATA)>
<!ELEMENT MiddleName (#PCDATA)>
<!ELEMENT LastName (#PCDATA)>
]>

The DTD above is interpreted like this :

Internal DTD
External DTD

If the DTD is declared inside the XML file, it must be wrapped inside the definition :

Person.xml

<?xml version="1.0" ?>
<!DOCTYPE Person
[
<!ELEMENT Person (FirstName, MiddleName?, LastName)>
<!ELEMENT FirstName (#PCDATA)>
<!ELEMENT MiddleName (#PCDATA)>
<!ELEMENT LastName (#PCDATA)>
]>

<Person>
<FirstName>Debabrata</FirstName>
<LastName>Panchadhyay</LastName>
</Person>
<Person>
<FirstName>Kedar</FirstName>
<MiddleName>Nath</MiddleName>
<LastName>Panchadhyay</LastName>
</Person>

If the DTD is declared in an external file, the definition must contain a reference to the DTD file :

Document.dtd

<!ELEMENT Person (FirstName, MiddleName?, LastName)>
<!ELEMENT FirstName (#PCDATA)>
<!ELEMENT MiddleName (#PCDATA)>
<!ELEMENT LastName (#PCDATA)>


Person.xml

<?xml version="1.0" ?>
<!DOCTYPE Person SYSTEM "Document.dtd">
<Person>
<FirstName>Debabrata</FirstName>
<LastName>Panchadhyay</LastName>
</Person>
<Person>
<FirstName>Kedar</FirstName>
<MiddleName>Nath</MiddleName>
<LastName>Panchadhyay</LastName>
</Person>




Example 1

StudentDocument.dtd
<!ELEMENT Student (StudentID, Name, Address, Phone+, Email, SubjectMarks+)>
<!ELEMENT StudentID (#PCDATA)>
<!ELEMENT Name (#PCDATA)>
<!ELEMENT Address (House, Street, City, State, Pincode)>
<!ELEMENT House (#PCDATA)>
<!ELEMENT Street (#PCDATA)>
<!ELEMENT City (#PCDATA)>
<!ELEMENT State (#PCDATA)>
<!ELEMENT Pincode (#PCDATA)>
<!ELEMENT Phone (#PCDATA)>
<!ATTLIST Phone PhoneType (Personal|Home) "Personal">
<!ELEMENT Email (#PCDATA)>
<!ELEMENT SubjectMarks (SubjectCode, Marks)>
<!ELEMENT SubjectCode (#PCDATA)>
<!ELEMENT Marks (#PCDATA)>

Student.xml
<?xml version="1.0" ?>
<!DOCTYPE Student SYSTEM "StudentDocument.dtd">
<Student>
<StudentID>105508022</StudentID>
<Name>Debabrata Panchadhyay</Name>
<Address>
<House>12/18</House>
<Street>Padmapukur Road</Street>
<City>Kolkata</City>
<State>West Bengal</State>
<Pincode>700064</Pincode>
</Address>
<Phone PhoneType="Personal">9748516231</Phone>
<Phone PhoneType="Home">9073919231</Phone>
<Email>info@questionsolves.com</Email>
<SubjectMarks>
<SubjectCode>MCS-41</SubjectCode>
<Marks>52</Marks>
</SubjectMarks>
<SubjectMarks>
<SubjectCode>MCS-42</SubjectCode>
<Marks>65</Marks>
</SubjectMarks>
<SubjectMarks>
<SubjectCode>MCS-43</SubjectCode>
<Marks>68</Marks>
</SubjectMarks>
</Student>




Example 2

OrderDocument.dtd
<!ELEMENT CustomerOrder (Customer, Order*)>
<!ELEMENT Customer (CustomerID, Name, Address+, Phone+)>
<!ELEMENT CustomerID (#PCDATA)>
<!ELEMENT Name (FirstName, MiddleName?, LastName)>
<!ELEMENT FirstName (#PCDATA)>
<!ELEMENT MiddleName (#PCDATA)>
<!ELEMENT LastName (#PCDATA)>
<!ELEMENT Address (House, Street, City, State, Pincode)>
<!ATTLIST Address AddressType (Billing|Home) "Home">
<!ELEMENT House (#PCDATA)>
<!ELEMENT Street (#PCDATA)>
<!ELEMENT City (#PCDATA)>
<!ELEMENT State (#PCDATA)>
<!ELEMENT Pincode (#PCDATA)>
<!ELEMENT Phone (#PCDATA)>
<!ELEMENT Order (OrderNo, Product+,BillAmount)>
<!ELEMENT OrderNo (#PCDATA)>
<!ELEMENT Product (ProductName, UnitPrice,Quantity,TotalAmount)>
<!ELEMENT ProductName (#PCDATA)>
<!ELEMENT UnitPrice (#PCDATA)>
<!ELEMENT Quantity (#PCDATA)>
<!ELEMENT TotalAmount (#PCDATA)>
<!ELEMENT BillAmount (#PCDATA)>

Order.xml
<?xml version="1.0" ?>
<!DOCTYPE CustomerOrder SYSTEM "OrderDocument.dtd">
<CustomerOrder>
<Customer>
<CustomerID>24685</CustomerID>
<Name>
<FirstName>Debabrata</FirstName>
<LastName>Panchadhyay</LastName>
</Name>
<Address AddressType="Home">
<House>12/18</House>
<Street>Padmapukur Road</Street>
<City>Kolkata</City>
<State>West Bengal</State>
<Pincode>700092</Pincode>
</Address>
<Address AddressType="Billing">
<House>AE 609</House>
<Street>Saltlake Sector I</Street>
<City>Kolkata</City>
<State>West Bengal</State>
<Pincode>700064</Pincode>
</Address>
<Phone>9748516231</Phone>
<Phone>9073919231</Phone>
</Customer>
<Order>
<OrderNo>325</OrderNo>
<Product>
<ProductName>Kingstone Pendrive 8GB</ProductName>
<UnitPrice>300</UnitPrice>
<Quantity>10</Quantity>
<TotalAmount>3000</TotalAmount>
</Product>
<BillAmount>3000</BillAmount>
</Order>
<Order>
<OrderNo>340</OrderNo>
<Product>
<ProductName>Intel i5 Processor (7 Generation)</ProductName>
<UnitPrice>14000</UnitPrice>
<Quantity>1</Quantity>
<TotalAmount>14000</TotalAmount>
</Product>
<Product>
<ProductName>Kingstone 8 GB DDR4 RAM</ProductName>
<UnitPrice>6000</UnitPrice>
<Quantity>2</Quantity>
<TotalAmount>12000</TotalAmount>
</Product>
<Product>
<ProductName>WD Harddisk 2TB</ProductName>
<UnitPrice>4500</UnitPrice>
<Quantity>2</Quantity>
<TotalAmount>9000</TotalAmount>
</Product>
<BillAmount>35000</BillAmount>
</Order>
</CustomerOrder>



ABOUT US

QuestionSolves.com is an educational website that helps worldwide students in solving computer education related queries.

Also, different software like Visual Studio, SQL Server, Oracle etc. are available to download in different versions.

Moreover, QuestionSolves.com provides solutions to your questions and assignments also.


MORE TOPIC


Windows Command

UNIX Command

IGNOU Assignment Solution

IGNOU Question Paper Solution

Solutions of Different Questions


WHAT WE DO


Website Devlopment

Training

Home Learning

Provide BCA, MCA Projects

Provide Assignment & Question Paper Solution


CONTACT US


Follow Us