XML Syntax

XML achieves its flexibility by allowing you to extend a base markup language (the XML specification itself) with tags of your own design. You create tags to structure the text within a document so that its underlying meaning is clearly presented. For example, to denote an item on an invoice, you could use an <ITEM> tag.

While XML and HTML documents look a lot alike, there are several important syntactical differences. HTML is fairly flexible. You can omit end tags from many of an HTML document’s most important structures, such as list items, and most browsers will happily display the document as best they can. XML documents, however, must meet a more rigid set of requirements:

  • A document must begin with a line that identifies it as XML. It must also include the XML specification with which it complies. Since XML is a brand-new standard, this line is currently <?xml version="1.0"?>.[23]

  • Tags are case sensitive. For example, <INVOICE_NUMBER> and <invoice_number> are not the same. In general, the convention is to always use uppercase.

  • All attribute values must appear in quotes, as in <CUSTOMER CUST_ID="12345">.

  • A start tag must always have a corresponding end tag. The combination of a start tag (plus any attributes), an end tag, and any intervening text is called an element.

  • Elements cannot overlap. For example, the following set of markups is illegal: <INVOICE_ITEM><PART_NUM>PN-1234</INVOICE_ITEM></PART_NUM>.

  • “Empty” tags that don’t mark up any text, like HTML’s <p> or <br> ...

Get Oracle Web Applications: PL/SQL Developer's Intro now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.