- Rule 1: All XML Must Have a Root Element
- Rule 2: All Tags Must Be Closed
- Rule 3: All Tags Must Be Properly Nested
- Rule 4: Tag Names Have Strict Limits
- Rule 5: Tag Names Are Case Sensitive
- Rule 6: Tag Names Cannot Contain Spaces
- Rule 7: Attribute Values Must Appear Within Quotes
- Rule 8: White Space Is Preserved
- Rule 9: Avoid HTML Tags (Optional)
Rule 3: All Tags Must Be Properly Nested
When you insert (nest) one tag within another, pay attention to the order in which you open each tag, and then close the tags in the reverse order. If you open element A and then element B, you must first close B before closing A. Even HTML tags that usually will work without a strict structure must follow the stricter XML rules when they’re used within an XML file.
Wrong:
<A><B>Text</A></B> <b><i>Text</b></i>
Right:
<A><B>Text</B></A> <b><i>Text</i></b>