Skip to content

Latest commit

 

History

History
97 lines (69 loc) · 2.59 KB

xml.md

File metadata and controls

97 lines (69 loc) · 2.59 KB

XML

what is XML?

  • XML stands for EXtensible Markup Language

It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable.

source: Wikipedia

Rules

tags ...

  • this is an (opening) tag: <someName>
  • this is a closing tag: </someName>
  • this is a tag: <someName>some content</someName>
  • this is an empty tag: <someName/>

... and attributes

  • attributes only live inside opening tags
  • this is an attribute with a value: <someName attribute="value">

names of tags and attributes

Tip

Your XML-Editor should know the rules and inform you in case of any violation

start and end tag

<tag>text</tag>

Respect the hierarchy / no overlapping mark up

<parent>
    <child></child>
</parent>
<parent>
    <child></parent>
</child>

avoid or encode special characters

always

  • < should be written as &lt;
  • > should be written as &gt;
  • & should be written as &amp;

in attributes

  • ' should be written as &apos;
  • " should be written as &quot;

Rules for Naming Tags and Attributes

(generated by GitHub-Copilot using GPT 4o)

  1. Start with a letter or underscore: Names must start with a letter (a-z or A-Z) or an underscore (_).
  2. They cannot start with a number or punctuation character.
  3. Follow with letters, digits, hyphens, underscores, and periods: After the initial character, names can include letters, digits (0-9), hyphens (-), underscores (_), and periods (.).
  4. No spaces: Names cannot contain spaces.
  5. Case-sensitive: XML names are case-sensitive. For example, <Tag> and <tag> are considered different tags.
  6. Avoid XML reserved words: Names should not match XML reserved words like xml, XML, Xml, etc.

Characters Not Allowed in Names

Names cannot start with a number or punctuation character. Names cannot contain spaces. Names cannot contain the following characters: !, @, #, $, %, ^, &, *, (, ), +, =, {, }, [, ], |, , :, ;, ", ', <, >, ,, ?, /.

Examples

valid names

<tagName>content</tagName>
<_tagName>content</_tagName>
<tag-name>content</tag-name>
<tag.name>content</tag.name>
<tag123>content</tag123>

invalid names

<123tag>content</123tag> <!-- Starts with a number -->
<tag name>content</tag name> <!-- Contains a space -->
<tag!name>content</tag!name> <!-- Contains an exclamation mark -->