What is the difference between well-formed and valid XML document?
W3C, in the XML specification, has defined certain rules that needs to be followed while creating XML documents. The examples of such rules include: having exactly one root element, having end-tag for each start- tag, using single/double quotes for attribute values, and so on. If an XML document follows all these rules, it is said to be well-formed document and XML parsers can be used to parse and process such documents.
Document Type Definitions (DTDs) or XML Schemas can be used to define the structure and content of a specific class of XML documents. This includes the parent-child relationship details, attribute lists, data type information, value restrictions, etc. In addition to the well-formedness rules, if an XML document also follows the rules specified in the associated DTD/Schema, it is said to be a valid XML document. All valid XML documents are well-formed; but the reverse is not always true, that is, well-formed XML documents do not necessarily have to be valid.
What is XML, and why it is gaining such a momentum?
Answer :
XML, or Extensible Markup Language, is an excellent way of representing data in a structured format. The most popular application of XML is for data-exchange. Like HTML, XML is also a textual, tag-based “markup” language. However, unlike HTML, which has a fixed set of tags and focuses on “presentation”, XML does not have any fixed set of tags, and XML is all about “data”. It is possible to create our own tags, and write data inside these tags in an XML document. The XML data is structured in a hierarchical format, and there are many “parsers” available that allow easily getting to the data values.
Some of the reasons behind XML’s success include:
* The ability to define and use our own tags makes XML “extensible”, and self-describing.
* XML’s textual nature makes it highly portable allowing us to send and receive data from one platform to the other without any issues (such as encoding).
* The availability of many free XML parsers and processors, makes it really easy to create, read, and manage XML documents.
* As mentioned earlier, XML is all about data. Separating “presentation” from the actual “content” has many benefits, including the flexibility of providing/presenting data to multiple destinations/devices.
* The availability of various other standards surrounding the XML (such as XSLT, XPath, and XML Schema); and support for these standards in various toolkits/APIs.
* XML is the “standard” backed by W3C and supported by major vendors.
In addition to data-exchange, XML is being used for various other purposes, such as content management, XML-based configuration files, eBusiness, document publishing, application integration, and most notably XML-based messaging or Web services





