Click to return to the XML (Extensible Markup Language) home page    
Knowledge Base Articles     Overview    
Web Workshop  |  XML (Extensible Markup Language)

Frequently Asked Questions


Printing this FAQ?

General Questions about Extensible Markup Language (XML)

Technical Questions

What is the difference between well-formed XML and valid XML?

Well-formed XML documents must contain matching start and end tags, and tags cannot overlap. For example, the following example is well-formed:
<?xml version="1.0"?>
<person>
  <name>John Doe</name>
  <occupation>Software Engineer</occupation>
</person>
Whereas, this example is not well-formed (<name> and <occupation> tags overlap, and there is no <person> end tag):
<?xml version="1.0"?>
<person>
  <name>John Doe
  <occupation>Software Engineer
  </name>
  </occupation>
Valid XML documents must conform to a Document Type Definition (DTD). The following example is a valid XML document that conforms to person.dtd:
<?xml version="1.0"?>
<!DOCTYPE PERSON SYSTEM "person.dtd">
<person>
  <name>John Doe</name>
  <occupation>Software Engineer</occupation>
</person>
All valid XML documents are well-formed; however, a well-formed document is not valid unless it conforms to a DTD.

Should XML in the XML processing instruction (PI) be in uppercase or lowercase letters?

XML in the XML processing instruction (PI), and its attributes, must be in lowercase letters, for example:
<?xml version="1.0"?>

Are quotes required for attribute values in XML documents?

Yes. Unlike in HTML, all attribute values must be quoted in XML documents. the following example shows a correctly quoted certified attribute for the <occupation> element:
<?xml version="1.0"?>
<person>
  <name>John Doe</name>
  <occupation certified="Y">Software Engineer</occupation>
</person>
The following example shows an incorrectly specified certified attribute (not quoted) for the <occupation> element.
<?xml version="1.0"?>
<person>
  <name>John Doe</name>
  <occupation certified=Y>Software Engineer</occupation>
</person>
Attributes may be quoted using single quotes (for example, certified='Y') or double quotes (for example, certified="Y"). Quotes must be used in matching pairs.

Is </> a valid XML end tag?

No. XML does not allow </> as an end tag. Matching start and end tags must be present, for example:

SGML, from which XML is derived, allows </> as a valid end tag.

Can XML tags be mixed with text?

Yes. If the content model for the element is MIXED -- that is, it contains the #PCDATA keyword -- then the elements can have text interspersed between them.

In the following example, the XML data for the <person> element is valid because the person element contains the #PCDATA keyword:

<?xml version="1.0" ?>
<!DOCTYPE person [
<!ELEMENT person (#PCDATA|lastname|firstname)>
<!ELEMENT lastname (#PCDATA)>
<!ELEMENT firstname (#PCDATA)>
]>
<person>
  My first name is <firstname>John</firstname>
  and my last name is <lastname>Smith</lastname>
</person>


Back to topBack to top

© 1999 Microsoft Corporation. All rights reserved. Terms of use.