XML is popular for many features and few of them are listed here:
- Easy Data Exchange: In XML, data and markup are stored as text that we can configure. If we like, we can use XML editors to create XML documents but if something goes wrong we can examine and modify document directly because it’s all just text.XML provides a very efficient way of storing most data. In addition, when we standardize markup languages, many different people can use them.
- Customizing markup language: We can create customized markup languages using XML, and that represents its extraordinary power. We can create a customized browsers to handle that language.
- Self describing data: The data in XML document is self describing. We can create our own tags in XML so that if we will go back to our document years later, we can figure out what’s going on.
- Structured and integrated data: In XML document we can specify not only data but the structure of that data can also be specified. When we are dealing with complex and important data we can integrate various elements in to other elements.
- Well-formed XML documents: XML document must follow the syntax rules set up properly. Each element also must nest inside any enclosing elements properly. for example if in any example of XMl we are opening a tag but not closing the same then it is not a well formed XML document.
- Valid XML document: An XML document is valid if there is a document type definition (DTD) associated with it and if the document complies with that DTD.
The XML Declaration
We can start XML documents using XML declaration. But it is totally optional that we want to use that declaration or not. The XML declaration provides at a minimum the number of the version of XML in use:
Currently, 1.0 is the only approved version of XML, but others may appear in the future.
There are few other important rules to keep in mind about the XML declaration:
a)The XML declaration is case sensitive: it may not begin with “
b)If the XML declaration appears at all, it must be the very first thing in the XML document: not even whitespace or comments may appear before it; and
c)It is legal for a transfer protocol like HTTP to override the encoding value that you put in the XML declaration, so you cannot guarantee that the document will actually use the encoding provided in the XML declaration.
d)Elements may not overlap: an end tag must always have the same name as the most recent unmatched start tag. The following example is well-formed XML document.
- An XML document has exactly one root element. As a result, the following example is not a well-formed XML document, because both the university and books elements occur at the top level:
The following example fixes the problem by including both the University and Books elements within a new Education root element:
- answered 4 years ago
- B Butts