View the Most Wanted LQ Wiki articles.
LinuxQuestions.org > Linux Wiki > XML

From LQWiki

Jump to: navigation, search

XML stands for the eXtensible Markup Language, which is a flexible language used for sharing data and format over networks in a structured way. XML derived from SGML and resembles HTML in some ways. However, where HTML has been twisted to serve presentational ends, XML is more concerned with data and XHTML more rigidly enforces a focus on structure. For example, here is some (very) simple HTML:

<html>
<body text="green" bgcolor="orange">
<p>
Hi there. This is a paragraph, marked by the 'p' tag. 
It also contains some <b>bold</b> text. And here 
is some <i>emphasized</i> text. End of paragraph.
</p>
</html>

So you can see that this HTML is mixing presentation and structure. Proper HTML would remove the attributes to the body element and place them (hopefully with different values!) in a CSS stylesheet. The 'bold' and 'italic' elements (which connote presentation) would be replaced with 'strong' and 'em' (which simply convey degrees of importance). The 'html' and 'p' are the only things specifying what sort of document it is and what sort of structure it has. However, web browsers understand all these presentational mixtures and have become superb at wading through 'tag soup'. XHTML, as an application of XML, enforces well-formedness and its DTD contains no presentational elements. Contrariwise, HTML elements are fixed. There are no private namespaces or document types. XML is extensible, meaning you can create elements and assign them values with the proper namespaces and DTD.

Here's some (very) simple XML:

<content>
  <person name="Bob">
    <address>123 Bob's Street<address>
    <phone>0123 456 789</phone>
  </person>
  <person name="Alice">
    <address>456 Some Other Road<address>
    <phone>0987 654 321</phone>
  </person>
</content>

XML is about storing data, and it doesn't much care about displaying it, because that's the job of CSS or XSLT or whatever else overlays or transforms the XML markup. These tags (the person, address, phone words inside square brackets) are not fixed - the developer can put in whatever he likes, and once again it is the responsibility of the reading software to make sense of them and apply its own display styles.

XML is a W3C Recommendation.

External links


Personal tools