Difference between revisions of "XML"

From Wikicliki
Jump to: navigation, search
Line 1: Line 1:
 +
The diference between XML and HTML is that XML was designed to transport and store data, while HTML was designed to display data.
 +
 +
XML does not do anything. It merely holds information. It has no predefined tags. You invent your own tags in XML. Its not a replacement for HTML, which can only use HTML tags, and is meant to display information and format it in pretty ways.
 +
 
As long as only well-formedness is required, XML is a generic framework for storing any amount of text or any data whose structure can be represented as a tree. The only indispensable syntactical requirement is that the document has exactly one root element (alternatively called the document element). This means that the text must be enclosed between a root start-tag and a corresponding end-tag.  
 
As long as only well-formedness is required, XML is a generic framework for storing any amount of text or any data whose structure can be represented as a tree. The only indispensable syntactical requirement is that the document has exactly one root element (alternatively called the document element). This means that the text must be enclosed between a root start-tag and a corresponding end-tag.  
  
The diference between XML and HTML is that XML was designed to transport and store data, while HTML was designed to display data.
+
well formed XML:
 +
 
 +
# XML elements must be properly nested and not overlap
 +
<font color=green>#* CORRECT: <title> Romeo and Juliet <author> Shakespeare </author> </title></font>
 +
#* WRONG: <title> Romeo and Juliet <author> Shakespeare </title> </author>
 +
# Empty elements may contain attributes
 +
#* All the following are correct:
 +
<font color=green>#* <food name="orange"></food></font>
 +
<font color=green>#* <food name="orange" /></font>
 +
<font color=green>#* <food name="orange"/></font>
  
 
== XPath ==  
 
== XPath ==  

Revision as of 10:15, 17 September 2008

The diference between XML and HTML is that XML was designed to transport and store data, while HTML was designed to display data.

XML does not do anything. It merely holds information. It has no predefined tags. You invent your own tags in XML. Its not a replacement for HTML, which can only use HTML tags, and is meant to display information and format it in pretty ways.

As long as only well-formedness is required, XML is a generic framework for storing any amount of text or any data whose structure can be represented as a tree. The only indispensable syntactical requirement is that the document has exactly one root element (alternatively called the document element). This means that the text must be enclosed between a root start-tag and a corresponding end-tag.

well formed XML:

  1. XML elements must be properly nested and not overlap

#* CORRECT: <title> Romeo and Juliet <author> Shakespeare </author> </title>

    • WRONG: <title> Romeo and Juliet <author> Shakespeare </title> </author>
  1. Empty elements may contain attributes
    • All the following are correct:

#* <food name="orange"></food> #* <food name="orange" /> #* <food name="orange"/>

XPath

XPath may be used to compute values (strings, numbers, or boolean values) from the content of an XML document.