Quy tắc đặt tên XML
Các phần tử XML phải tuân theo các quy tắc đặt tên sau:
- Element names are case-sensitive
- Element names must start with a letter or underscore
- Element names cannot start with the letters xml(or XML, or Xml, etc)
- Element names can contain letters, digits, hyphens, underscores, and periods
- Element names cannot contain spaces
Bất kỳ tên nào cũng có thể được sử dụng, không có từ nào được đặt trước (trừ xml).
Thực tiễn Đặt tên Tốt nhất
- Create descriptive names, like this: <person>, <firstname>, <lastname>.
- Create short and simple names, like this: <book_title> not like this: <the_title_of_the_book>.
- Avoid "-". If you name something "first-name", some software may think you want to subtract "name" from "first".
- Avoid ".". If you name something "first.name", some software may think that "name" is a property of the object "first".
- Avoid ":". Colons are reserved for namespaces (more later).
- Non-English letters like éòá are perfectly legal in XML, but watch out for problems if your software doesn't support them.
Kiểu đặt tên
Không có kiểu đặt tên nào được xác định cho các phần tử XML. Nhưng đây là một số thường được sử dụng:
- Lower case <firstname> All letters lower case
- Upper case <FIRSTNAME> All letters upper case
- Underscore <first_name> Underscore separates words
- Pascal case <FirstName> Uppercase first letter in each word
- Camel case <firstName> Uppercase first letter in each word except the first
tham khảo
http://www.w3schools.com/xml/xml_elements.asp