Extensible Markup Language
Extensible Markup Language
• Introduction
• Comparison between XML and HTML
• XML Syntax
What is XML?
• eXtensible Markup Language
• Markup language for documents containing
structured information
• Defined by four specifications:
– XML, the Extensible Markup Language
– XLL, the Extensible Linking Language
– XSL, the Extensible Style Language
– XUA, the XML User Agent
XML….
• Based on Standard Generalized Markup
Language (SGML)
• Version 1.0 introduced by World Wide Web
Consortium (W3C) in 1998
• Bridge for data exchange on the Web
Comparisons
XML HTML
• Extensible set of • Fixed set of tags
tags
• Content orientated • Presentation oriented
• Standard Data • No data validation
infrastructure capabilities
• Allows multiple • Single presentation
output forms
XML Elements
• Example:
<XML ID=“XMLID”>
<customer>
<name> Mark Hanson </name>
<custID> 29085 </custID>
</customer>
</XML>
• An XML document with correct syntax is
called "Well Formed".
JavaScript Object Notation
What is JSON?
• Strings in JSON
{ "name":"John" }
• JSON Numbers
• Numbers in JSON must be an integer or a floating
point.
{ "age":30 }
• JSON Objects
{
"employee":
{ "name":"John", "age":30, "city":"New York" }
}
• JSON Arrays
{
"employees":[ "John", "Anna", "Peter" ]
}
• JSON Booleans
{ "sale":true }
• JSON null
{ "middlename":null }
JSON - Evaluates to JavaScript Objects
• Both JSON and XML can be used to receive data from a web server.
• The following JSON and XML examples both define an employees
object, with an array of 3 employees:
In XML:
<employees>
<employee>
<firstName>John</firstName> <lastName>Doe</lastName>
</employee>
<employee>
<firstName>Anna</firstName> <lastName>Smith</lastName>
</employee>
<employee>
<firstName>Peter</firstName> <lastName>Jones</lastName>
</employee>
</employees>
In JSON
• {"employees":[
{ "firstName":"John", "lastName":"Doe" },
{ "firstName":"Anna", "lastName":"Smith" },
{ "firstName":"Peter", "lastName":"Jones" }
]}