From WikiEducator
< VirtualMV‎ | XML‎ | Rules
Jump to: navigation, search

Six golden rules of XML

1. All XML documents begin with

<?xml version="1.0" encoding="…"?>

2. All XML documents must have one(and only one) root element

3. All XML elements must have a closing tag

 <p>This is a paragraph</p>
 <emptytag /><emptytag></emptytag>

4. XML tags are case sensitive

<name> and <NAME> are not the same

5. All XML elements must be properly nested

Your <b><i>yuck</b></i> days are over

6. Attribute values must always be quoted

<note date="25 may 2006"></note>

Well-formed versus Valid

  • A "Well Formed" XML document has correct XML syntax
  • A "Valid" XML document also conforms to a DTD or XSD

Some features

  • Comments
  <!-- This is a comment -->
  • Adding data that is not to be parsed (e.g. inserting HTML into an XML file
  <![CDATA[ no parsing here ]]>
  • White space
  • Namespaces: Allow you to cope with merging two XML files which have the same tags but for different purposes (e.g. Merging a Staff file with a student file.
  • Escape Characters
    &lt; < less than
    &gt; > greater than
    &amp; & ampersand
    &apos; ' apostrophe
    &quot; " quotation mark