Question -
Answer -
Structure of XML- File/Document
Every XML document includes both physical and logical structure which are as follows:
1. Physical Structure
It contains the actual data used in a document. The basic storage unit called entity, each of which may refer to other entities. An entity has a name and content. It contains references to other entities. There is a special entity called document entity or root, that serves as a main storage unit. XML processor always start document processing from that unit.
We have three classifications of entities, these are as follows:
1. Internal and External Entities
For internal entity, there is no separate physical storage object and the content of the entity is given in the declaration. It contained inside the document. If the entity is not internal, then it is an external entity.
2. General and Parameter Entities
General entities are entities which are used within the document content. In this specification, general entities are sometimes referred to with the unqualified entity, when this leads to no ambiguity. Generally, entities are declared and used differently. Parameter entities are parsed and used only in the DTD part of the XML document.
3. Parsed and Unparsed Entities
Parsed entities contain text that is referred as replacement text intended to be processed by the parser and is considered as an integral part of the document. Unparsed entities are resources that can be of any type including text objects. This type of entity is never process by parser.
2. Logical Structure
It is a template that enables the elements to be included in a document and in the order in which they have to be included.
The logical structure includes the basic components of the XML document. It indicates how a document is built, irrespective of what a document contains. The first structural element is prolog which is the base for the logical structure.
The structure of the document of example code: