Q5. What rules do you need to keep in mind while defining XML elements?
Ans. The following are some rules that need to be considered while defining XML elements:
- Elements names can start with letters or the underscore (_) character, but not numbers or punctuation characters.
- After the first character, you can use numbers and characters, such as hyphen (-) and period (.), in the characters.
- Element names cannot contain spaces.
- Element names cannot contain the: character because it is reserved character or keyword (that is, it has specific meaning in XML) in the XML specification. Therefore, you should avoid using it in your documents.
- Element names cannot start with the word xml in any form (XML or Xml or xml).
- Element names cannot have a blank space after the opening character (<); the name of the element must come immediately after it. However, there can be space before the closing character (>).