Sample code that explains the correct format of xml documents in detail

黄舟
Release: 2017-03-30 13:41:04
Original
1542 people have browsed it

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>
Copy after login

---------- -------------------------------------------------- --------------------

"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>
Copy after login

--------------------------------------------- -------------------------------------

XML DTD
DTD definition 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 DTDs.

W3C makes DTD and Schema interchangeable. Readers can learn more in the Schema Guide.

-------------------------------------------------- ------------------------------------

Error
occurred in XML document An error will cause the XML program to stop.

The W3C XML specification states: If a program finds a valid error in processing an XML document, 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 There are different ways to decide how this HTML file should be displayed.

This never happens in XML.

The above is the detailed content of Sample code that explains the correct format of xml documents in detail. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!