next page page above previous page

Next: XHTML Up: Lecture 8 Previous: XML Document Structure

XML Syntax

XML tags

Example of several XML errors

<?xml version="1.0" encoding="UTF-8"?>
<item type=mango>
  <price> 6 euros </Price>
  <Description> nice
    <weight> 127 grammes
  </Description> </weight>
</item>
<item type="pear" quality="good" type="pear">
  <price> 2.53 euros
</item>

One way of correcting these errors:

<?xml version="1.0" encoding="UTF-8"?>
<basket>
  <item type="mango">
    <price> 6 euros </price>
    <Description> nice </Description>
    <weight> 127 grammes </weight>
  </item>
  <item type="pear" quality="good">
    <price> 2.53 euros </price>
  </item>
</basket>

New element <basket> is introduced to get a solo root element.

XML parsers always reject bad XML unlike HTML parsers.


Lecture 8XHTML 1.0Slide 9