Because XML can customize tags, the set of tags defined by each person is different. if there is no set of standards to define tags, the application cannot process XML documents. The solution to this problem uses DTD and DTD (DocumentTypeDefinition, Document Type Definition) to define the compiling rules of XML documents. Because XML can customize tags, the set of tags defined by each person is different. if there is no set of standards to define tags, the application cannot process XML documents. The solution to this problem uses DTD and DTD (Document Type Definition, Document Type Definition) to define the compiling rules of XML documents. For example, which elements can be included in the document and the requirements of the content and attributes of the elements. The application uses this DTD to verify the document. XML documents that comply with the DTD constraints are called valid documents. you can proceed with the next step. Otherwise, an error is reported, the application can capture the error and handle the exception accordingly. The inspection process is optional, depending on the specific application.
Document Type Declaration
To use DTD for validity verification, you must use the Document Type Definition declaration to specify the DTD. For example:
Jims
Jims@163.com
Jims@21cn.com
The document type declaration is after the XML declaration and before the root element. If the dtd document is located on the local machine, the path name can be used to indicate the location of the document. The content of portal. dtd is as follows:
The above content can also be directly written into the XML document. This dtd declaration method is called the internal dtd subset, for example:
]>
Jims
Jims@163.com
Jims@21cn.com
If the dtd is outside the XML document, it is called an external dtd subset. We can combine the internal and external dtd to form a dtd to verify the XML document. For example:
]>
Note: When using internal and external dtd, the two dtd must be compatible with each other and cannot conflict with each other.
The above is the detailed content of the XML document type declaration. For more information, see other related articles in the first PHP community!