All About Elements

The most important (and frequently encountered) type of markup is the element tag. An element consists of an element open tag (for example, <name>), which is possibly followed by character data and additional elements, and an element close tag (</name>). Unlike HTML, XML requires that element open and close tags must match. This means that if an element begins with a <name> tag, it must end with a matching </name> closing tag. Mismatched tags will generate a well-formedness error (like a syntax error) in an XML parser. For example, the following tag sequence would generate an error if it were used in an XML document:

<p>This is the first line,<br>and this is the second.</p>

Although this is a perfectly valid HTML tag sequence, XML does not automatically close the <br> tag upon parsing the </p> close tag. To fix this, either the <br> tag must be closed with a </br> end tag or the empty element syntax must be used.

The empty element syntax is simply a shortcut for encoding elements that contain no character data or markup. This is the empty element syntax:

<tagname/>

This is a normal open tag that ends with a / character before the closing >. To an XML parser, this is equivalent to an empty open and close tag combination, like this:

<tagname></tagname>

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.3.43