Encoding XML element name beginning with a number?

后端 未结 5 1068
隐瞒了意图╮
隐瞒了意图╮ 2020-12-03 17:11

I\'m looking at the output of a tool, dumping a database table to XML. One of the columns is named 64kbit , the tool encodes that as such, and I need to rep

5条回答
  •  再見小時候
    2020-12-03 17:42

    Well, it doesn't seem to be too standard, but XML explicitly disallows numbers (and some other things) as the first character of an element name:

    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]
    

    This encoding here just kinda escapes the first character if it doesn't fit that requirements. It uses the hexadecimal value of that character. _x0036_ obviously corresponds to hexadeximal 0x36 which is 54 in decimal and represents the digit 6.

提交回复
热议问题