Introduction to XML, Defining XML tags, their attributes and values, Document Type Definition, XML Schemas, Document Object Model, XHTML Parsing XML Data - DOM and SAX Parsers in java.
How to Troubleshoot Apps for the Modern Connected Worker
WEB TECHNOLOGIES XML
1. WEB TECHNOLOGIES XML
Dr R Jegadeesan Prof-CSE
Jyothishmathi Institute of Technology and Science,
karimnagar
2. Syllabus
XML
Introduction to XML, Defining XML
tags, their attributes and values,
Document Type Definition, XML
Schemas, Document Object Model,
XHTML Parsing XML Data - DOM and
SAX Parsers in java.
2
3. UNIT - II : XML
Aim & Objective :
➢ To introduce XML and processing of XML Data.
➢ XML is widely used in the era of web development. It is also used to
simplify data storage and data sharing.
Features & Advantages of XML
3
4. UNIT - II : XML
Main Features of XML :
The main features or advantages of XML are
1) XML separates data from HTML
➢ If you need to display dynamic data in your HTML document, it will take a lot of work to edit the
HTML each time the data changes.
➢ With XML, data can be stored in separate XML files. This way you can focus on using HTML/CSS
for display and layout, and be sure that changes in the underlying data will not require any
changes to the HTML.
➢ With a few lines of JavaScript code, you can read an external XML file and update the data
content of your web page.
Features & Advantages of XML
4
5. UNIT - II : XML
2) XML simplifies data sharing
➢ In the real world, computer systems and databases contain data in incompatible formats.
➢ XML data is stored in plain text format. This provides a software- and hardware-independent
way of storing data.
➢ This makes it much easier to create data that can be shared by different applications.
3) XML simplifies data transport
➢ One of the most time-consuming challenges for developers is to exchange data between
incompatible systems over the Internet.
➢ Exchanging data as XML greatly reduces this complexity, since the data can be read by
different incompatible applications.
Features & Advantages of XML
5
6. UNIT - II : XML
4) XML simplifies Platform change
➢ Upgrading to new systems (hardware or software platforms), is always time consuming. Large
amounts of data must be converted and incompatible data is often lost.
➢ XML data is stored in text format. This makes it easier to expand or upgrade to new operating
systems, new applications, or new browsers, without losing data.
5) XML increases data availability
➢ Different applications can access your data, not only in HTML pages, but also from XML data
sources.
➢ With XML, your data can be available to all kinds of "reading machines" (Handheld computers,
voice machines, news feeds, etc), and make it more available for blind people, or people with
other disabilities.
Features & Advantages of XML
6
7. UNIT - II : XML
XML Documents Must Have a Root Element
XML documents must contain one root element that is the parent of all other elements:
<root>
<child>
<subchild>.....</subchild>
</child>
</root>
In this example <note> is the root element:
<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Varun</to>
<from>Joel</from>
<heading>Happy message</heading>
<body>Don't forget me this weekend!</body>
</note>
Features & Advantages of XML
7
8. UNIT - II : XML
The XML Prolog
➢ This line is called the XML prolog:
<?xml version="1.0" encoding="UTF-8"?>
➢ The XML prolog is optional. If it exists, it must come first in the document.
➢ To avoid errors, you should specify the encoding used, or save your XML files as UTF-8.
➢ UTF-8 is the default character encoding for XML documents.
➢ UTF-8 is also the default encoding for HTML5, CSS, JavaScript, PHP, and SQL.
Features & Advantages of XML
8
9. UNIT - II : XML
All XML Elements Must Have a Closing Tag
➢ In XML, it is illegal to omit the closing tag. All elements must have a closing tag:
<p>This is a paragraph.</p>
<br />
Note: The XML prolog does not have a closing tag! This is not an error. The prolog is not a part of
the XML document.
XML Tags are Case Sensitive
XML tags are case sensitive. The tag <Letter> is different from the tag <letter>.
Opening and closing tags must be written with the same case:
<message>This is correct</message>
Features & Advantages of XML
9
10. UNIT - II : XML
XML Elements Must be Properly Nested
➢ In HTML, you might see improperly nested elements:
➢ <b><i>This text is bold and italic</b></i>
➢ In XML, all elements must be properly nested within each other:
➢ <b><i>This text is bold and italic</i></b>
➢ In the example above, "Properly nested" simply means that since the <i> element is
opened inside the <b> element, it must be closed inside the <b> element.
Features & Advantages of XML
10
11. UNIT - II : XML
XML Attribute Values Must Always be Quoted
➢ XML elements can have attributes in name/value pairs just like in HTML.
➢ In XML, the attribute values must always be quoted:
➢ <note date="12/11/2007">
<to>Varun</to>
<from>Joel</from>
</note>
Features & Advantages of XML
11
12. UNIT - II : XML
Entity References
➢ Some characters have a special meaning in XML.
➢ If you place a character like "<" inside an XML element, it will generate an error because
the parser interprets it as the start of a new element.
➢ This will generate an XML error:
<message>salary < 1000</message>
➢ To avoid this error, replace the "<" character with an entity reference:
➢ <message>salary < 1000</message>
There are 5 pre-defined entity references in XML:
➢ < < less than
➢ > > greater than
➢ & & ampersand
➢ ' ‘ apostrophe
➢ " “ quotation mark
➢Only < and & are strictly illegal in XML, but it is a good habit to replace > with > as well.
Features & Advantages of XML
12
13. UNIT - II : XML
Example XML Program
<?xml version="1.0"?>
<bio-data>
<name> Varun</name>
<address>Tamilnadu</address>
</bio-data>
Note: the XML files can be saved with .xml extension
Features & Advantages of XML
13
14. UNIT - II : XML
Well Formed XML
XML documents that conform to the syntax rules above are said to be "Well Formed" XML
documents.
XML Naming Rules
XML elements must follow these naming rules:
Element names are case-sensitive
Element names must start with a letter or underscore
Element names cannot start with the letters xml (or XML, or Xml, etc)
Element names can contain letters, digits, hyphens, underscores, and periods
Element names cannot contain spaces Any name can be used, no words are reserved (except
xml).
Rules of XML
14
15. UNIT - II : XML
➢ XML elements can have attributes, just like HTML.
➢ Attributes are designed to contain data related to a specific element.
XML Attributes Must be Quoted
➢ Attribute values must always be quoted. Either single or double quotes can be used.
➢ For a person's gender, the <person> element can be written like this:
<person gender="female">
or like this:
<person gender='female'>
➢ If the attribute value itself contains double quotes you can use single quotes, like in this
example:
<gangster name=‘Welcome to “JITS" Campus'>
➢ or you can use character entities:
<gangster name=“Welcome " JITS" Campus">
XML Attributes
15
21. UNIT II: XML
Features & Advantages of XML
21
Book Details :
TEXT BOOKS:
1. Web Technologies, Uttam K Roy, Oxford University Press
2. The Complete Reference PHP – Steven Holzner, Tata McGraw-Hill
REFERENCE BOOKS:
1.Web Programming, building internet applications, Chris Bates 2nd edition, Wiley Dreamtech
2. Java Server Pages –Hans Bergsten, SPD O’Reilly
3. Java Script, D. Flanagan, O’Reilly,SPD.
4. Beginning Web Programming-Jon Duckett WROX.
5. Programming World Wide Web, R. W. Sebesta, Fourth Edition, Pearson.
6. Internet and World Wide Web – How to program, Dietel and Nieto, Pearson.
22. UNIT II : XML
Features & Advantages of XML
22
Video Link details (NPTEL, YOUTUBE Lectures and etc.)
➢https://nptel.ac.in/content/storage2/nptel_ data3/html/mhrd/ict/text/106106093/lec39.pdf
➢http://www.nptelvideos.in/2012/11/internet-technologies.html
➢https://www.btechguru.com/training--programming--xml--xml-attributes--xml-attributes-
part2-video-lecture--11783--24--147.html
23. UNIT II : XML
Features & Advantages of XML
23
courses available on <www.coursera.org>, and http://neat.aicte-india.org
https://www.coursera.org/
Course 1 : Web Applications for Everybody Specialization
Build dynamic database-backed web sites.. Use PHP, MySQL, jQuery, and Handlebars to build web
and database applications.
Course 2: Web Design for Everybody: Basics of Web Development & Coding Specialization
Learn to Design and Create Websites. Build a responsive and accessible web portfolio using
HTML5, XML, CSS3, and JavaScript
24. UNIT II : XML
XML Tutorials
24
Tutorial topic wise
➢https://www.w3schools.com/xml/
➢https://www.tutorialspoint.com/xml/index.html
➢https://beginnersbook.com/2018/10/xml-tutorial-learn-xml/
➢http://www.xmlmaster.org/en/article/d01/
25. UNIT II : XML
XML MCQs
25
XML – MCQs
1.XML stands for ______________.
a) None of these b) Extensible Markup Language
C)Extensible Mashup Language d)Extended Mashup Language
2.XML is designed to ______________ and store data.
a)transport b)None of these
c)design d)verify
3.XML is much more similar like ______________.
a)C Programming b)CSS
c)JavaScript d)HTML
4.Which of the following is not a function of XML?
a)Store Information b)Transport Information.
c)Structure Information d)Style Information
5.XML deals with storage and ______________transport of data.
a)Transport b)Design
c)Minify d)Filter
26. UNIT II : XML
XML Tutorial Problems
26
XML –Tutorial Problems:
1.Write a XML to populate data to web pages
2.Write a php program to extract data from XML
27. UNIT II : XML
XML Questions
27
XML –universities & Important Questions:
1. Explain and show how XML is useful in defining data for web applications.
2. Explain the various terms related to Document Type Definition.
3. Design an XML schema for hospital information management. Include every feature
available with schema.
4. Explain how styling XML with cascading style sheets is done for the library information
domain.
5. List and Explain the important features of XML which make it more suitable than HTML for
creating web related services.
6. Define an xml scheme to show how an XML Scheme can be created
7. Define Attributes in XML .Also different types of attributes.
8. List the elements in XML .Also different types of content of Elements.
9. How do you define the elements of an XML document in an XML Schema?
10. How do you set default and fixed values for simple Elements?