Professional Documents
Culture Documents
in/trb-study-materials/
XML Introduction
1. XML Stands for EXtensible Mark-up Language (XML).
2. SGML Electronic Publishing challenges -1986
3. HTML Web Presentation challenges -1991
4. XML Data Representation challenges -1996
5. W3C- World Wide Web Consortium (W3C)
6. CSS- Cascading Style Sheets (CSS)
7. XML is the Universal format for Structuring Documents and Data on the Web.
8. Actually Extensible Mark-up Language is not a mark-up language, but a set of rules for
creating a new mark-up language.
9. XML is a Subset of Standard Generalized Mark-up Language (SGML).
10. SGML specifies the Rules for Creating Mark-up Languages.
11. The XML 1.0 was made a World Wide Web Consortium (W3C) recommendation on
February 10, 1998.
XML is Replacement of HTML ?
1. One thing we must keep in our mind that XML is not a replacement for HTML. We can
treat it as complementary language for HTML
2. XML is used to represent the data contained in the tags. HTML is used to represent web
pages
3. XML is used to carry information. More clear answer of this question is explained
beautifully
4. In order to write XML file we must have text editor.
5. Our recommendation is to use Notepad++ for Editing and Writing XML files.
6. Save this Document with .xml extension
Difference between XML and HTML :
HTML XML
V.MANIKANDAN. M.Sc.,B.Ed.,M.Phil.,CCNA
Paavai Engineering College,Namakkal-18. E_Mail ID: vmaniapt@Gmail.com
http://www.tnbedcsvips.in/trb-study-materials/
HTML XML
HTML does not preserve white space XML preserves White Space
HTML XML
Date when
1990 1996
invented
No strict rules. Browser will still generate Strict rules must be followed or processor
Processing/Rules
data to the best of its ability will terminate processing the file
V.MANIKANDAN. M.Sc.,B.Ed.,M.Phil.,CCNA
Paavai Engineering College,Namakkal-18. E_Mail ID: vmaniapt@Gmail.com
http://www.tnbedcsvips.in/trb-study-materials/
How to Parse XML Document ?
1. An XML processor is more commonly called a parser.
2. XML Parser parses XML and provides needed information to the application.
3. XML Parser reads document characters by character and determines which
characters are part of the document’s markup and which are part of the
document’s data.
4. XML Parser does all processing of XML document before an application can make use
of it.
5. In market there are many Parser available from different Vendors.
Some Well Known XML Parsers :
1. Microsoft Internet Explorer Parser
Microsoft’s XML parser is known as MSXML.
MSXML first shipped with Internet Explorer 4.
The latest version of the parser is available for download from Microsoft’s MSDN site.
Comes built-in with the Internet Explorer browser.
2.Apache Xerces
The Apache Software Foundation’s Xerces subproject of the Apache XML Project has
resulted in XML parsers in Java and C++, plus a Perl wrapper for the C++ parser.
These tools are free, and the distribution of the code is controlled by the GNU Public
License (GPL).
3. James Clark’s Expat
Completely Written in C.
It is free for both private and commercial use
Can be Downloaded From Here.
4.Xml4j
Created and Owned By IBM.
Completely written in Java.
Available for free.
Different XML Editors :
XML Notepad
XML Cooktop
XML Pro
XML Spy
Liquid XML Studio http://www.tnbedcsvips.in/trb-study-materials/
V.MANIKANDAN. M.Sc.,B.Ed.,M.Phil.,CCNA
Paavai Engineering College,Namakkal-18. E_Mail ID: vmaniapt@Gmail.com
http://www.tnbedcsvips.in/trb-study-materials/
Features of XML Editor :
1. Easy XML Syntax Highlighting.
2. Drag and Drop Tags.
3. More Readable XML Document.
4. Increases Performance Time of Writing XML Document.
5. Can Create Well Formed XML Document.
XML Declaration :
<?xmlversion="1.0"encoding="UTF-8"standalone="no"?>
1. XML Declaration is Optional.
2. XML Declaration must be First Line in XML Document if we write Declaration.
3. XML Declaration tells that Document Written is in XML.
4. XML Declaration tells XML Version used to Write Document.
5. XML Declaration tells Encoding Style Used to Encode XML Document.
6. If XML Document is standalone i.e if it does not depends on other external
document then we need to specify standalone=”yes”.
7. W3C recommends to include XML Declaration.
Document Type Definition (DTD)
<!DOCTYPE document system "Person.dtd">
1. Document Type definition is used to Define XML Document.
2. DTD is used when you Validate your XML document.
3. DTD can be Internal or External.
4. DTD rule tells which Element is allowed to nest inside Other Element.
Comment
1. Comments are Optional part of XML Document.
2. Comments in XML are similar to HTML . <!– and –>
3. Content Written inside Comment is ignored by Parser. (Comment part is not parsed by
Parser)
4. Comments can appear anywhere inside XML Document.
Styling and Processing Instruction
<?xml-stylesheettype="text/css"href="Styles.css"?>
1. Processing Instructions begin with <? and ends with ?>
2. Processing Instructions are instructions for the XML processor.
3. Processing instructions are processor dependant so not all processors understand all
processing instructions.
V.MANIKANDAN. M.Sc.,B.Ed.,M.Phil.,CCNA
Paavai Engineering College,Namakkal-18. E_Mail ID: vmaniapt@Gmail.com
http://www.tnbedcsvips.in/trb-study-materials/
White Space
1. White Space can be created using Carriage Return , Line Feed and Tab.
2. White Space cannot affect Parsing of Document.
3. User is Free to Use White Space anywhere inside document.
4. XML recommendation specifies that XML documents use the UNIX convention for
line endings.
5. It means that you should use a linefeed character only (ASCII code 10) to indicate the
end of a line.
Note:-
Root Node-<Student>
Sub Nodes-<Boy> and <Girl>
Sub-Sub Nodes-<name> and <marks>
Ex:
<Student>
<Boy name="Pritesh" marks="90"></Boy>
<Boy name="Pooja" marks="89"></Boy>
</Student>
V.MANIKANDAN. M.Sc.,B.Ed.,M.Phil.,CCNA
Paavai Engineering College,Namakkal-18. E_Mail ID: vmaniapt@Gmail.com
http://www.tnbedcsvips.in/trb-study-materials/
Root Element :
1. Each XML Document must have One and Only One Root Element.
2. Other XML elements must be Nested inside Root Element.
3. Opening Tag of Root Element is the Opening Tag of Document.
4. Closing Tag of Root Element is the Closing Tag of Document.
Some Facts:
1. XML is Organized as Tree Structure.
2. XML can have User Defined Tags.
3. XML consists of any number of nodes.
Elements & Content
Root element opening tag- <Person>
V.MANIKANDAN. M.Sc.,B.Ed.,M.Phil.,CCNA
Paavai Engineering College,Namakkal-18. E_Mail ID: vmaniapt@Gmail.com
http://www.tnbedcsvips.in/trb-study-materials/
XML Document Must have One and Only One Root Element.
In HTML many elements don’t have closing tags.
XML Element must have Closing Tag.
It is illegal to have non-closing tag in XML.
All XML Tags are Case Sensitive.
Opening Tag must have Closing tag with Same Case and Spelling.
Opening Tag Must have Same Spelling to that of Closing Tag.
Opening Tag and Closing Tags must have same Case.
HTML does not care improperly nested element. It does not show any error.
XML does Strict Checking of Elements.
It will give parsing error if Parser finds any Improper nesting of Elements.
What is XML Attribute ?
1. XML Attributes are just like “HTML Attributes“.
2. “XML Attributes” provides additional information about “XML Element“.
3. Attributes Consists of name/value pairs associated with an element.
4. Attributes are attached to the start-tag, but not to the end-tag
“Well Formed XML Document – ”
Rule No Explanation
http://www.tnbedcsvips.in/trb-study-materials/
V.MANIKANDAN. M.Sc.,B.Ed.,M.Phil.,CCNA
Paavai Engineering College,Namakkal-18. E_Mail ID: vmaniapt@Gmail.com
http://www.tnbedcsvips.in/trb-study-materials/
Main XML DTD Building Blocks :
XML Elements :
Ex:
<Book pages="100">
<name>Learn XML</name>
<author>Pritesh</author>
<type>Scripting</type>
</Book>
XML Entities :
< <
> >
& &
" “
' ‘
V.MANIKANDAN. M.Sc.,B.Ed.,M.Phil.,CCNA
Paavai Engineering College,Namakkal-18. E_Mail ID: vmaniapt@Gmail.com
http://www.tnbedcsvips.in/trb-study-materials/
PCDATA / CDATA :
PCDATA CDATA
PCDATA is text that will be parsed by CDATA is text that will not be parsed by a
a parser parser
Tags inside the text will be treated as Tags inside the text will NOT be treated as
markup and entities will be expanded markup and entities will not be expanded
DTD Elements :
DTD elements are declared with an ELEMENT declaration.
<!ELEMENT element-name keyword> OR
<!ELEMENT element-name (element-content)>
Different ways of using DTD Element :
We can use DTD element like below syntax –
Empty Elements :
EMPTY Keyword is used to specify Empty elements. Please look at following syntax –
<!ELEMENT element-name EMPTY>
V.MANIKANDAN. M.Sc.,B.Ed.,M.Phil.,CCNA
Paavai Engineering College,Namakkal-18. E_Mail ID: vmaniapt@Gmail.com
http://www.tnbedcsvips.in/trb-study-materials/
Example :
<!ELEMENT br EMPTY>
<br />
<!ELEMENT hr EMPTY>
<hr />
!DOCTYPE
defines that the root element of this document is Book
bookDocument
V.MANIKANDAN. M.Sc.,B.Ed.,M.Phil.,CCNA
Paavai Engineering College,Namakkal-18. E_Mail ID: vmaniapt@Gmail.com