Intimate contact XML (4)---XML is sensitive to capitalization

Source: Internet
Author: User
Tags date closing tag end opening and closing tags version
xml| case

XML is sensitive to case
In XML, all elements must have an end tag, such as:

< P>this is a paragraph</p>
< P>this is another paragraph</p>

Note: From the previous example you may have noticed that the XML declaration has no end tag. This is not a mistake. Because the declaration is not part of an XML document. It is not an XML element, so it cannot have a closing tag.

XML is sensitive to capitalization, which is not like HTML. In XML, tags < letter> and tags < letter> are not the same. Therefore, opening and closing tags should be written in the same case:

< Message>this is incorrect</message>
< Message>this is correct</message>

All XML elements must be nested properly

If the markup is not nested properly, it is meaningless in XML. In HTML, some elements can be improperly nested with each other, for example:

< b>< i>this text is bold and italic</b></i>

In XML, all elements must be properly nested with each other, for example:

< b>< i>this text is bold and italic</i></b>

All XML documents must have a root tag

The first tag in an XML document is the root tag. All XML documents must contain a tag pair to define the root element. All other elements must be nested inside the root element. All elements can have child elements. Child elements must be properly nested within the parent element.

< root>
< child>
< subchild>.....</subchild>
</child>
</root>

Attribute value must be caused to

In XML, it is illegal to omit quotes around property values. Like HTML, XML elements can have attributes in their name/value pairs. In XML, attribute values must be generated. Take a look at the following two XML documents. The first one is correct and the second one is wrong:

< XML version= "1.0"?>
< note date=12/11/99>
< to>tove</to>
< from>jani</from>
< heading>reminder< Body>don ' t forget me this weekend!</body>
</note>

< XML version= "1.0"?>
< note date= "12/11/99" >
< to>tove</to>
< from>jani</from>
< heading>reminder< Body>don ' t forget me this weekend!</body>
</note>

The first error in the document is that the data attribute in the note element is not generated. This is true: date= "12/11/99". This is wrong: date=12/11/99.

In XML, spaces are reserved

In XML, the space for a document cannot be deleted. This is not like HTML. In HTML, a word like this: Hello my name is Tove, which will be displayed like this: Hello my name is Tove, because HTML removes whitespace.

In XML, CR/LF is converted to LF

In XML, a new row is usually stored as LF. Do you know what a typewriter is? Typewriters were a type of machine equipment used in the last century. When you have a line on your typewriter, you have to manually return to the left blank and hand in the paper. In a Windows application, a new line in the text is usually stored as a CR LF character pair. In a UNIX application, a new line is usually stored as an LF character. Some applications store new rows with only one CR character.

XML is nothing special.

There is nothing special about XML. It's just a plain text file plus some XML tags contained in parentheses. Software that can handle plain text can also process XML. In a simple text editor, XML tags are visible and do not require any special processing. However, in your application, you must specifically handle XML tags. Depending on the nature of the application, the markup may or may not be visible, or have a functional significance.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.