Sunday, March 2, 2014

Introduction to xml

In this post i am going to give an Introduction of XML technology.

What is XML?


  • XML stands for eXtensible Markup Language.
  • XML is designed to transport and store data.
  • It is not a programming language, i's a markup language.
  • It is a specification of W3C(World Wide Web Consortium)
Markup : Enclosing textual content with in textual code(tags) is nothing but markup.

Purpose :  
  • Used to exchange the information
  • XML documents are used as deployment discriptors
  • Used as textual databases.

Syntax with example :

<?xml version="1.0" encoding="utf-8"?>
<student>
   <sno>10</sno>
   <sname>sudeep</sname>
   <sage>18</sage>
</student>

Well-Formness
It indicates the readability nature of an XML document.
  1. XML Document start with PROLOG.
  2. Start tag must have a matching end tag.
  3. Root element.
  4. Level constraint.
  5. Attribute values must be quoted.
  6. Elements are case sensitive.
XML Element.

1. Start element <eleementname>
2. End element </elementname>
An element can contain
  1. Other elements
  2. Text
  3. Attribute
  4. Mix of all

XML Attribute

If you want to add supplementary information attah to an element, instead of having another element.
  1. Attribute is unique in xml
  2. It can occur in any order.

Avoid using attributes.
  1. It can not contain multiple values.
  2. More difficult to manipulate code
Entities :
                &lt;                           :                  <
                &gt;                          :                  >
                &amp;                      :                  &
                &quot;                      :                  "
                &apos;                     :                   '
                &copy;                     :                   c

Naming Rules :

  1. names can contain letters, numbers and other characters.
  2. name cannot start with number or punctuation characters.
  3. Names cannot start wiht the letters xml.

Best Practices :

  1. Make names descriptive.
  2. Names should be short and simple.
  3. Avoid using hyphen(-), period(.) and colon(:) in the code.

 Validating XML :

If an xml document is developed accorrding to rules specified in DTD/XSD.
Validating xml can be done by :
  1. XML Parsers.
  2. XML Editors.

XML Parser :

It's an API that enables XML applications to work with xml document. It performs
  1. Reading the XML document.
  2. Checking the well-formedness
  3. Verify its validity. 
  4. Making XML data available to XML applications.

XML Editors :

XML Editors are just like text editors which have the feature to check well-formness of our XML document and to validate the same.

The best one is Altova XMLSpy. You can download a windows version here. Unfortunately Altova doesn't provide Linux version for XMLSpy. 

IDE's also have the feature of validating and checking the well-formedness of xml document.

No comments:

Post a Comment