XML Basic Concepts
Foreword
This article is intended to provide a quick introduction to basic concepts about XML.
Structured and semantic markup
An essential characteristic of structured markup is that it explicitly specifies the structure and semantic content of a document. It does not mark up the way in which the document will be displayed in the screen, printing, or anywhere else.
XML use named elements, delimited by angle brackets (“<” and “>”) to identify the markup in a document. Note the following features of this markup:
- Clarity
-
Every element should in tags(”< >”), and a starting tag (<element>) is always followed by a ending tag (</element>). An empty tag should be written as <element />
- Hierarchy
- For example, in XHTML, the inline element code (which means a piece of code) cannot contain a block element p (which means a paragraph).
Semantic markup makes your documents more amenable to interpretation by software. And it makes possible to apply different styles to the same document without rewriting it.
Elements and Attributes
XML markup consists primarily of elements, attributes, and entities.
Elements are the terms we have been speaking about most, like p, that describe a document’s content and structure.
Most elements are represented by pairs of tags and mark the start and end of the construct they surround. For example, <strong>strong</strong>. Some elements are “empty”, e.g. <hr />.
Elements can, but don’t necessarily, include one or more attributes, which are additional terms that extend the function or refine the content of a given element. For example, in XHTML 1.1, the element a, usually has a href attribute, whcih specifies the target, like this: <a href="http://example.com">. End tags cannot contain attributes.
Entities
Mostly, we use entities to type in some special characters. For example, “<” and “>” has special meaning in XHTML file. Therefore, if you write XHTML files manually and want to type “<” or “>” literal, you should type “>” and “<” instead. Also, some characters such as © are hard to type. Instead, you can just type “©″.
There are other uses and other types of entities, which I won’t discuss here.
More Information
Refer to Extensible Markup Language for more information.
Leave a Reply