Home > Articles > Web Services > XML

  • Print
  • + Share This
This chapter is from the book

Attribute Rules

Attribute type names are subject to the same naming rules and conventions as elements. The names are case sensitive, so NAME and name are not the same:

  • Attribute names cannot contain spaces. An attribute could be called FirstName but not First Name.

  • Attribute names must begin with a letter (or the underscore). So, Four11 would be an acceptable attribute, whereas 411 would not.

  • Attribute values must be enclosed in quotation marks.

  • An element may have only one attribute of a given name.

  • Attribute content may not contain <, >, or &.

Although attribute content must be contained in quotation marks, you can nest quotation marks within attribute content. To nest quotations, you simply use double quotation marks and single quotation marks, in either order:

<NAME First="John 'Stinky'" Last="Doe"/>


<NAME First='John "Stinky"' Last="Doe"/>

As long as the quotation marks are properly nested, the order in which you use single versus double quotation marks does not matter.

  • + Share This
  • 🔖 Save To Your Account