This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
notes:xml_cheat_sheet [2026/07/30 16:54] 123.21.87.226 old revision restored (2026/07/12 19:39) |
— (current) | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ===== XML Cheat Sheet ===== | ||
| - | |||
| - | I stumble across XML documents intermittently and every time I need to review the basics again. This is a cheat sheet so that I can review it whenever I need to. Information here is a summarized form of the [[http:// | ||
| - | |||
| - | ==== What is XML ==== | ||
| - | |||
| - | E**X**tensible **M**arkup **L**anguage (XML) is a markup language designed to describe data. It has no predefined tags and uses a Document Type Definition (DTD) or an XML Schema to describe the data. An XML document together with its DTD or XML Schema is self-descriptive. | ||
| - | |||
| - | XML uses text files to store data and can be used to create new languages e.g. WAP, WML, XHTML etc. | ||
| - | |||
| - | ==== XML Syntax ==== | ||
| - | |||
| - | A simple XML document : | ||
| - | |||
| - | < | ||
| - | <?xml version=" | ||
| - | <note date=" | ||
| - | < | ||
| - | < | ||
| - | </ | ||
| - | </ | ||
| - | |||
| - | * The first line is an XML declaration which defines the XML version and the character encoding used in the document. | ||
| - | |||
| - | * XML tags are case-sensitive and must have a corresponding closing tag. Tags must be properly nested. | ||
| - | |||
| - | * An XML document must have a root element (note in the above). All elements may have child elements. | ||
| - | |||
| - | * XML documents can be extended by adding new element types. Implementations must ignore unknown element types. | ||
| - | |||
| - | * Whitespace is preserved. CR/LF is converted into just LF (UNIX format line terminators). | ||
| - | |||
| - | * <!-- This is a comment --> | ||
| - | |||
| - | ==== XML Elements ==== | ||
| - | |||
| - | XML Elements can have attributes which must be either single or double quoted e.g. date in the above. | ||
| - | |||
| - | XML elements can have either | ||
| - | * Empty content | ||
| - | * Simple content(text ony) | ||
| - | * Element content (child elements) | ||
| - | * Mixed content (child elements and text) | ||
| - | |||
| - | XML element names can contain any character except for a space but must start with a letter and can't start with xml (in any case). | ||
| - | |||