1 of 11

Web Technologies

XML

Smt.M.Jeevana Sujitha

Assistant Professor

Department of Computer Science and Engineering

SRKR Engineering College, Bhimavaram, A.P. - 534204

2 of 11

OBJECTIVES

The Objectives of this lecture are

  • To learn about what is XML and rules for writing XML document.
  • To learn about advantages of XML.

3 of 11

XML

  • The XML stands for "Extensible Markup Language".
  • This is similar to HTML. That means this language contains various tags.
  • But those tags are not predefined tags, user can define his own tags.

4 of 11

XML

Difference between HTML & XML:

  • The difference between HTML and XML is that HTML is designed for “representation of data” on the web page.
  • Where as XML is designed to “transport” or to “store the data”.

5 of 11

XML

Elements and Attributes:

  • In XML, the basic entity is element.
  • The elements are used for defining the tags.
  • The elements consist of opening and closing tag.

Syntax:

<element-name> content </element-name>

Example:

<person>

<person-info>

<name>srinu</name>

<city>palakollu</city>

</person-info>

<hobby>

<first>Reading news paper</first>

<second>Playing cricket</second>

</hobby>

</person>

6 of 11

XML

Rules for writing XML document:

  • XML is case sensitive language. Example: <hobby> painting </Hobby>
  • In XML each start tag must have matching end tag.

Example: <hobby> painting

  • The elements in XML must be properly nested. Example:

<one>

<two> srinu</one>

</two>

7 of 11

XML

Rules for writing XML document:

  • A space or tab character is not allowed in the element

name or in attribute name.

Example: <per son> srinu </per son>

  • The attributes must be enclosed with double quotes or a

single quote.

Example: <person flag=“true”> </person>

  • There are some characters in XML which have special

meanings.

Example:

&lt; for lessthan

&gt; for greater than &amp; for ampersand &quot; for double quotes

8 of 11

Comments in XML document:

XML

  • The syntax for writing comments in XML is similar to HTML comments.

Syntax:

<!–- This is comment line -->

9 of 11

XML

Namespace in XML:

  • The XML allows us to create different elements which are having the common name. This technique is called “namespace”

Example:

<File-description>

<text fname=“input.txt”>

<describe> It is text file</describe>

</text>

<text fname=“flower.jpg”>

<describe> It is an image file</describe>

</text>

<File-description>

10 of 11

Advantages of XML:

  • XML document is human readable
  • The XML language is language neutral
  • Every XML document has tree structure
  • XML is platform independent language

XML

11 of 11

THANK YOU