Difference between revisions of "XML"

From Wikicliki
Jump to: navigation, search
(XPath)
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
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.
 +
 
 +
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.
 +
 
 +
== Wellformed-ness ==
 +
 
 +
# 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>
 +
# You can define entities
 +
#* 5 predeclared entities for symbols: <code> &amp; , &lt; &gt; &apos; &quot; </code>
 +
#* Define an entity in the DTD: <code><!DOCTYPE example [ <!ENTITY copy "&#xA9;"> ]></code> and then call it up with &copy;
 +
#* You can have entitites inside entities as long as they are declared in order.
 +
 
 +
== Displaying XML ==
 +
 
 +
* if you feed an xml doc straight to a browser, it will be rendered as raw xml text. (some with handles on margin)
 +
* you can render it with css but then your xml must have this: <code><?xml-stylesheet type="text/css" href="myStyleSheet.css"?></code>
  
 
== XPath ==  
 
== XPath ==  
Line 7: Line 29:
 
* [http://www.zvon.org/xxl/XPathTutorial/General/examples.html XPath tutorials]
 
* [http://www.zvon.org/xxl/XPathTutorial/General/examples.html XPath tutorials]
 
* [http://www.stylusstudio.com/xpath.html XPath tools]
 
* [http://www.stylusstudio.com/xpath.html XPath tools]
 +
 +
== See Also ==
 +
 +
*http://www.w3schools.com/xml/xml_syntax.asp

Latest revision as of 10:55, 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.

Wellformed-ness

  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>
  2. Empty elements may contain attributes
    • All the following are correct:
    • <food name="orange"></food>
    • <food name="orange" />
    • <food name="orange"/>
  3. You can define entities
    • 5 predeclared entities for symbols: & , < > ' "
    • Define an entity in the DTD: <!DOCTYPE example [ <!ENTITY copy "©"> ]> and then call it up with ©
    • You can have entitites inside entities as long as they are declared in order.

Displaying XML

  • if you feed an xml doc straight to a browser, it will be rendered as raw xml text. (some with handles on margin)
  • you can render it with css but then your xml must have this: <?xml-stylesheet type="text/css" href="myStyleSheet.css"?>

XPath

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

See Also