Tandilashvili
Tandilashvili

Reputation: 93

Allowed symbols in XML element name

The symbols: hyphen -, under-score _ and period . are allowed in element name. The XML example is valid.

<?xml version="1.0" encoding="UTF-8"?>
<student>
   <first-name>George</first-name>
   <phone.mobile>(011) 123-4567</phone.mobile>
   <native_language>English</native_language>
   <city />
</student>

Is there any other symbol that is also allowed in XML element name?

Upvotes: 4

Views: 6797

Answers (2)

kjhughes
kjhughes

Reputation: 111491

The characters allowed in XML element names are given by the W3C XML BNF for component names:

NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] |
                  [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] |
                  [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] |
                  [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] |
                  [#x10000-#xEFFFF]
NameChar      ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] |
                  [#x203F-#x2040]
Name          ::= NameStartChar (NameChar)*

See also


Upvotes: 12

Joop Eggen
Joop Eggen

Reputation: 109532

Right: Letter, digit, hyphen, underscore and period.

One may use any Unicode letter.

And of course one may prefix the names with name space + colon.

Upvotes: 0

Related Questions