Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to XML Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.

Similar presentations


Presentation on theme: "Introduction to XML Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University."— Presentation transcript:

1 Introduction to XML Kanda Runapongsa (krunapon@kku.ac.th)krunapon@kku.ac.th Dept. of Computer Engineering Khon Kaen University

2 168493: XML and Web Services (II/2546) 2 Outline What is XML? XML vs. HTML What are in XML Files? Elements Attributes Entities Comments Processing Instructions

3 168493: XML and Web Services (II/2546) 3 What is XML? XML stands for eXtensible Markup Language The standard for data interchange on the Web XML is a text-based markup language Identify data using tags which are acted as markup Tags are surrounded by Example: Students

4 168493: XML and Web Services (II/2546) 4 HTML vs. XML HTML was designed to display data but XML was designed to describe (identify) data Examples: HTML: display the text “Computer Engineering” in bold Computer Engineering XML: describe that “Computer Engineering” is a department Computer Engineering

5 168493: XML and Web Services (II/2546) 5 HTML vs. XML (Cont.) HTML tags are predefined but XML tags are defined by the XML author The XML author uses any XML tags that make sense for a given application For applications that use the same XML data, they have to agree on the tag names they intend to use HTML name tags are case insensitive but XML name tags are case sensitive

6 168493: XML and Web Services (II/2546) 6 Why XML? Simple and extensible License-free Platform independent International language support Read and edit XML using any standard text-editing tool

7 168493: XML and Web Services (II/2546) 7 XML Usage Exchange data XML and B2B (Business to Business) ebXML: Electronic Business using XML Share data Store data Create new languages WML: Wireless Markup Language

8 168493: XML and Web Services (II/2546) 8 Outline What is XML? XML vs. HTML What are in XML Files? Elements Attributes Entities Comments Processing Instructions

9 168493: XML and Web Services (II/2546) 9 A Sample XML Document Students Teacher XML and Web Services 2:00-3:30 PM Dept. of Computer Engineering

10 168493: XML and Web Services (II/2546) 10 Elements Represent a logical component of an XML document Elements can contain Other elements (sub-elements) Text (character data) The boundary of each element: marked w/ a tag which Starts with < Ends with > Example: Students

11 168493: XML and Web Services (II/2546) 11 Attributes Descriptive information attached to elements Attributes are set inside the start tag of an element Example: What are the difference between elements and attributes? Containment Number of occurrences

12 168493: XML and Web Services (II/2546) 12 Entities Some characters are used to markup text in an XML document To represent these characters There must be an alternative way to represent them In XML, entities are used to these special characters

13 168493: XML and Web Services (II/2546) 13 Entities for Special Characters CharactersEntities << >> && ‘&apos; “"

14 168493: XML and Web Services (II/2546) 14 Comments Comments begin with Comments can contain any data except the literal string -- An XML processor is not required to pass them along to an application

15 168493: XML and Web Services (II/2546) 15 Processing Instructions Give commands or information to an application that is processing the XML data Format: target is the name of the application that is expected to do the processing instructions is a string of characters that embodies the information or commands for the application to process

16 168493: XML and Web Services (II/2546) 16 CDATA Sections Instructs the parser to ignore most markup characters Consider a source code listing in an XML document. It might contain characters that the XML parser would ordinarily recognize as markup (< and & for example)

17 168493: XML and Web Services (II/2546) 17 CDATA Sections (Cont.) Example <![CDATA[ *p = &q; b = (i <= 3); ]]> Between the start of the section,, all character data is passed directly to the application

18 168493: XML and Web Services (II/2546) 18 Well-formed XML Documents A document can only be well-formed if it obeys the syntax of XML Requirement for well-formed documents Elements must have a closing tag Elements must be properly nested XML documents must have a root element Attribute values must always be quoted Well-formed XML documents make it easier to process XML data

19 168493: XML and Web Services (II/2546) 19 Schema of XML Documents Specify allowed XML elements and the relationships between these elements Facilitate the validation and processing Several XML Schema languages have been developed. DTD: Document Type Definition XML Schema


Download ppt "Introduction to XML Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University."

Similar presentations


Ads by Google