85. Explain about XML attributes

Attributes are simple name/value pairs associated with an element.

They are attached to the start-tag, as shown below, but not to the end-tag:

<name nickname=”sharat”>
<first>sharat</first>
<middle></middle>
<last>lastname</last>
</name>

Attributes must have values–even if that value is just an empty string (like “”)–and those values must be in quotes.

Attributes Can Provide Meta Data that May Not be Relevant to Most Applications Dealing with Our XML

Attributes are Un-Ordered

Elements Can Be More Complex Than Attributes.

84. What do you mean by well-formed XML

XML documents must adhere to following rules to be well-formed.

  1. Every start-tag must have a matching end-tag, or be a self-closing tag
  2. Tags can’t overlap
  3. XML documents can have only one root element
  4. Element names must obey XML naming conventions
  5. XML is case-sensitive
  6. XML will keep whitespace in your text