Home  >  Article  >  Backend Development  >  XML Guide - XML ​​Validation

XML Guide - XML ​​Validation

黄舟
黄舟Original
2017-02-11 15:35:212033browse


An XML document that conforms to the grammar is called a well-structured XML document.
An XML document that passes DTD validation is called a valid XML document.



"Well-structured" XML document
A well-structured XML document should use correct syntax.
A well-structured XML document should comply with XML syntax rules. The example given in the previous chapter is a well-structured XML document:

<?xml version="1.0" encoding="ISO-8859-1"?> 
<note> 
<to>Tove</to> 
<from>Jani</from> 
<heading>Reminder</heading> 
<body>Don&#39;t forget me this weekend!</body> 
</note>





"Valid" XML document
A valid XML document should comply with the description of the DTD.
A valid XML document is also a well-structured XML document and must also comply with the rules of the DTD.

<?xml version="1.0" encoding="ISO-8859-1"?> 
<!DOCTYPE note SYSTEM "InternalNote.dtd"> 
<note> 
<to>Tove</to> 
<from>Jani</from> 
<heading>Reminder</heading> 
<body>Don&#39;t forget me this weekend!</body> 
</note>

XML DTD
DTD defines the legal elements available in XML documents.
The purpose of DTD is to define the legal building blocks of XML documents. He determines the internal structure of the XML document by defining a series of legal elements. A well-structured XML document is not necessarily a valid XML document, but a valid XML document must be a well-structured XML document. If you want to learn more about DTD, you can refer to the DTD Guide.

XML Schema
XML Schema (XML Schema) is a replacement for XML-based DTD.
W3C makes DTD and Schema interchangeable. Readers can learn more in the Schema Guide.

Error
An error that occurs in the XML document will cause the XML program to stop.
The W3C XML specification states: If a program finds a valid error in processing an XML document, then the program SHOULD terminate. This is why XML software is relatively easy to write. All XML documents should be consistent.
In HTML, HTML files may contain many errors (for example, an element has a start tag but no end tag). This is also one of the reasons why HTML browsers are so large. When they find errors, they have different method to determine how this HTML file should be displayed.
This never happens in XML. ​

The above is the content of the XML Guide-XML Confirmation. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn