An element can contain other elements, simple text or a mixture of both. Elements can also have attributes.
XML elements must follow these naming rules:
- Names can contain letters, numbers, and other characters
- Names cannot start with a number or punctuation character
- Names cannot start with the letters xml (or XML, or Xml, etc)
- Names cannot contain spaces
Best Naming Practices
Make names descriptive. Names with an underscore separator are nice:Names should be short and simple, like this:
Avoid "-" characters. If you name something "first-name," some software may think you want to subtract name from first.
Avoid "." characters. If you name something "first.name," some software may think that "name" is a property of the object "first."
Avoid ":" characters. Colons are reserved to be used for something called namespaces (more later).
XML documents often have a corresponding database. A good practice is to use the naming rules of your database for the elements in the XML documents.
Non-English letters like éòá are perfectly legal in XML, but watch out for problems if your software vendor doesn't support them.
XML Elements are Extensible
XML Attributes
XML elements can have attributes in the start tag, just like HTML.
Attributes provide additional information about elements.
XML Attributes Must be Quoted
Some of the problems with using attributes are:
|
No Response to "XML Elements,Attributes"
Post a Comment