XML: Learning to speak the language
June 24th, 2011XML is the ultimate flexible language and essential tool, a must learn for any programmer who seeks to achieve maximum programming power and efficiency. It is the basis of various languages such as XHTML, the front end for many inter program communication interfaces such as web based APIs, and is often used as a simple yet powerful transparent data storage system.
The power of XML comes from the simplicity behind its design. Learning to speak this language involves just set of simple rules, and its inherent undefined purpose allows this language to be utilized in many different ways. Languages such as HTML have similar structure, but HTML is designed to only hold web content, making it limited in use.
Here’s an example of an XML document:
&x3C;&x6C;&x65;&x74;&x74;&x65;&x72;&x3E; &x3C;&x74;&x6F;&x3E;&x4A;&x6F;&x68;&x6E;&x3C;&x2F;&x74;&x6F;&x3E; &x3C;&x66;&x72;&x6F;&x6D;&x3E;&x4A;&x61;&x6E;&x65;&x3C;&x2F;&x66;&x72;&x6F;&x6D;&x3E; &x3C;&x6D;&x65;&x73;&x73;&x61;&x67;&x65;&x3E;&x48;&x65;&x6C;&x6C;&x6F;&x2C;&x20;&x4A;&x6F;&x68;&x6E;&x21;&x3C;&x2F;&x6D;&x65;&x73;&x73;&x61;&x67;&x65;&x3E;&x3C;&x2F;&x6C;&x65;&x74;&x74;&x65;&x72;&x3E;
The basic structure of XML involves elements, or nodes, and data within those nodes. An element is structured as a beginning tag such as: &x3C;&x74;&x6F;&x3E;, followed by the data such as “John”, which is ended with the tag again, but with a front slash to denote the end of the tag, like this: &x3C;&x2F;&x74;&x6F;&x3E;.
The node highest in the hierarchy is known as the root node, or root element. Elements within this are child elements of the root element. These basic rules allow nesting of elements that can build complex data sets both computer readable and human readable. This is the basic idea behind the XML language, although there is more to learn, understanding these basic concepts is the primary hurdle when learning to speak this useful language.