Printing this FAQ?
<?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.
<?xml version="1.0"?>
<?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.
SGML, from which XML is derived, allows </> as a valid end tag.
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>