Difference between revisions of "XML"

From Wikicliki
Jump to: navigation, search
 
(One intermediate revision by the same user not shown)
Line 3: Line 3:
 
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.
 
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.
  
well formed XML:
+
== Wellformed-ness ==
  
 
# XML elements must be properly nested and not overlap
 
# XML elements must be properly nested and not overlap
 
#* <font color=green>CORRECT: <title> Romeo and Juliet <author> Shakespeare </author> </title></font>
 
#* <font color=green>CORRECT: <title> Romeo and Juliet <author> Shakespeare </author> </title></font>
#* <font color=red>WRONG: <title> Romeo and Juliet <author> Shakespeare </title> </author></font>
+
#* WRONG: <title> Romeo and Juliet <author> Shakespeare </title> </author>
 
# Empty elements may contain attributes
 
# Empty elements may contain attributes
 
#* All the following are correct:
 
#* All the following are correct:
#* <font color=green><food name="orange" state="decomposing"></food></font>
+
#* <font color=green><food name="orange"></food></font>
#* <font color=green><food name="orange" state="decomposing" /></font>
+
#* <font color=green><food name="orange" /></font>
#* <font color=green><food name="orange" state="decomposing"/></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 21: 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