An article takes you into XML syntax rules

王林
Release: 2019-08-26 13:48:16
forward
5454 people have browsed it

1. All XML elements must have closing tags

In HTML, you often see elements without closing tags:

<p>This is a paragraph
<p>This is another paragraph
Copy after login

In XML, It is illegal to omit the closing tag. All elements must have closing tags:

<p>This is a paragraph </p>
<p>This is another paragraph </p>
Copy after login

2. XML tags are case-sensitive

XML elements are defined using XML tags.

XML tags are case-sensitive. In XML, the tag is different from the tag .

Opening and closing tags must be written using the same case.

3. XML must be nested correctly

In HTML, you often see elements that are not nested correctly.

<b><i>This text is bold and italic</b></i>
Copy after login

In XML, all elements must be correctly nested within each other:

<b><i>This text is bold and italic</i></b>
Copy after login

Correct nesting means: since the element is opened within the element , then it must be closed within the element.

4. The XML document must have a root element

The XML document must have one element that is the parent element of all other elements. This element is called the root element.

<root>
   <child>
      <subchild>....</subchild>
   </child>
</root>
Copy after login

5. XML attribute values ​​must be quoted

<note date="08/08/2008"> </note>
Copy after login

An article takes you into XML syntax rules

Note: Only "" is legal, but it's a good practice to use an entity reference instead.

6. In XML, spaces will be preserved.

7. XML stores line breaks in LF

In window applications, line breaks are usually stored as one character: carriage return (CR) and Line feed (LF). This pair of characters has similarities to the action of a typewriter setting a new line. In Unix applications, new lines are stored as LF characters. Macintosh applications use CR to store new lines.

8. Summary:

All XML elements must have closing tags, opening tags and closing tags must be written in the same case, and must be nested correctly , there must be a root element, XML attribute values ​​must be quoted, etc. The syntax rules of XML are simple and logical. These rules are easy to learn and easy to use.

If you want to learn more related content, please visit the PHP Chinese website: XML video tutorial

The above is the detailed content of An article takes you into XML syntax rules. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
xml
source:csdn.net
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