|
XML Home
XML Tutorial About XML XML Viewers XML Editors XML Documents XML Syntax XML Elements XML Attributes XML with CSS XML with XSL XML Namespace XML Local Namespace XML Default Namespace XML Entities XML Creating Entities XML CDATA DTDDTD IntroductionDTD DOCTYPE DTD Internal DTD External DTD Combined DTD FPI DTD Elements DTD Element Operators DTD Attributes DTD Attribute Default Values DTD Attribute Types DTD General Entities DTD Parameter Entities DTD Embedded Images XSLTXSLT IntroductionXSLT Example XSLT Syntax XSLT <template> XSLT <apply-templates> XSLT <value-of> XSLT <for-each> XSLT <sort> XSLT <if> XSLT <choose> XPathXPath IntroductionXPath Location Path XPath Location Path - Absolute XPath Location Path - Relative XPath Attributes XPath Axis XPath Node Test XPath Predicate XPath Node Set XPath Comparison Operators XPath Boolean Operators XPath Number Operators XPath String Functions Tutorial Summary XHTML Tutorial AJAX Tutorial |
XML ElementsXML elements are represented by tags. Elements usually consist of an opening tag and a closing tag, but they can consist of just one tag. Opening tags consist of Example: <tag>Data</tag>
Empty elements are closed by inserting a forward slash before the greater than symbol. Example of empty tag:
The following syntax rules are important to note, especially if you're used to working with HTML where you don't usually need to worry about these rules. All Elements Must Be Closed ProperlyIf you're familiar with HTML, you will know that some HTML tags don't need to be closed. In XML however, you must close all tags. This is usually done in the form of a closing tag where you repeat the opening tag, but place a forward slash before the element name (i.e. Example for opening/closing tags:
Example for empty elements:
Tags Are Case SensitiveAll tags must be written using the correct case. XML sees Wrong:
Right:
Elements Must Be Nested ProperlyYou can place elements inside other elements but you need to ensure each element's closing tag doesn't overlap with any other tags. Wrong:
Right:
Element NamesYou can use any name you like for your elements as long as they adhere to the following rules:
You should using a colon (:) in your element names, as this is reserved for another purpose. |
Need Website Content?
Get unique, quality digital content for your website.
|