Sunday 28 April 2013

Beginning with XML


XML , a term you cannot ignore and find it everywhere. We will start learning about XML in a series of articles in this blog, right from understanding the basics of XML to understanding the various parser's used to parse the XML documents and the java to object binding frameworks.
So,What is XML?
  • XML stands for Extensible Markup Language.
  • It is designed to describe data and should be self descriptive.
  • It is used to store and transport data unlike HTML which is used to display data
  • One can define new tags/elements unlike HTML which is predefined.
When should we use XML?

  • Mainly it is used to store and transfer data.
  • It simplifies data sharing among disparate systems.

What is a well formed and valid XML?
Well formed - An XML is said to be well formed if it satisfies the following rules

  • All XML elements must have a closing tag
  • XML tags are case sensitive
  • XML documents must have a root element
  • XML attributes must be quoted.
  • XML elements can be nested
  • Entity references - some characters have special meaning like < and should be replaced with &lt;
  • White spaces are preserved

Valid XML - an XML is said to be valid if it conforms to the DTD or the XSD. We, will talk about these terms in the future blog,. Right now, it is sufficient to know that these contain the rules for the elements.

What does the XML contain?
XML documents starts with the root element and culminates into leaves. The XML documents contains the following

  • Declarations are nothing but processing instructions
  • Elements - XML contains at the start the root element and other elements as child elements to this root. Each child element can in turn contain other elements or text or attributes or mix of all. 
  • Attributes - contain additional information about the element it is part of. As in, it should be like an metadata (data about data).
Where is XML used?
  • In configuration files to define configuration for the application or its frameworks , e.g. web.xml, spring-config.xml etc
  • Used to transport messages in JMS e.g. XMLMessage
  • Used in web services, SOAP messages are XML messages.
  • Used to connect different applications via JMS or web services.

References
  • http://www.w3swchools.com

No comments:

Post a Comment