XML Language Learning

Source: Internet
Author: User

XML Language Learning

XML and HTML are both W3C custom standards. XML was born to replace immature HTML. However, XML has not been successfully replaced by HTML due to the actual environment. Later, W3C released the upgraded Markup Language XHTML for the sake of code rigor. However, it still failed to be promoted due to the main reason of the display environment. Now, we know the emergence of HTML5!

Simple XML features

1. more rigorous than HTML

2. Tree format

3. Sense of attention

XML Composition

1. Document declaration

2. Elements

3. Attributes

4. Notes

5. CDATA Zone

6. Special characters

7. processing commands

 

Document declaration

The Document declaration must exist in XML. Otherwise, it is definitely an nonstandard XML file. The statement is as follows: <? Xml version = "1.0" encoding = "UTF-8" standalone = "yes"?> <Xml>

Attribute version indicates that the version number is attached. Because XML is not successfully promoted, only version 1.0 is available in XML.

Attribute encoding Text encoding

Standalone runs independently. Appendix: This attribute rarely appears in daily use.

Description of text encoding declaration:

In daily life, we write the XML code and save the XML format file to the hard disk to convert it to binary. when the text is converted to binary, if it is stored on the server, some customers access this document, in this case, the server will send a binary code to the other party. After the other party receives the binary code, the browser will automatically decode the code to be understood, while the Chinese browser uses GBK encoding, while the tool for editing XML saves XML, it is usually UTF-8 encoding, in order to make the customer get the text, can see the correct content, at this point we need to declare the encoding format in the document for encoding = "UTF-8" so after the other side of the browser parses the binary, it will be automatically converted to UTF-8 instead of converted to GBK encoding garbled form display.

Element (tag/Tag)

1. The tag does not exist in the form of <br/> in HTML. XML is standardized and rigorous, so there must be a start tag and an end tag.

2. Like HTML, tags do not support cross-nesting.

3. A reasonable XML document contains only one root element, which fully reflects the tree structure.

4. For XML, spaces and line breaks are treated as content. Therefore, do not add spaces and line breaks as usual in XML documents!

5. XML is case sensitive, so make sure the case is not standard

Attribute

1. A tag can have multiple attributes, such as version, encoding, and other attributes, just like declaring a tag <XML> </XML>.

2. attribute values must be enclosed in double quotation marks according to XML specifications.

CDATA

In daily life, as I write notes now, special characters such as <> [] may appear, while <> in XML has special meanings. Generally, we can use escape characters for display. However, if the content is too large, it is troublesome. Therefore, XML provides CDATA partitions.

We only need to input the content before and after <! [CDATA [code]> tag, and then enter the content you want to write in the code area. XML does not define the special characters in this area as tags. <>, it is a normal text!

Three methods of browser parsing are attached: Parsing is to dynamically modify the document content in HTML or XML, and to query the specific content attributes of a tag in a structured manner.

DOM parsing: converts all labels to objects and stores them in the memory. In this way, resources can be freely called and modified, but resources are especially occupied in the memory.

SAX parsing: This parsing method will scan XML documents line by line. When a tag is encountered, it will trigger the parsing processor, usingEvent ProcessingXML (Simple API for XML) is not the official standard, but it is the de facto standard of the XML community. Almost all XML parsers support it. The advantage is that the XML can be processed while reading the document. It does not have to wait until the document is loaded and is relatively fast. It does not need to be loaded into the memory, so there is no memory occupation problem. You can parse the oversized XML. The disadvantage is that it can only be used to read data in XML. It cannot be added, deleted, or modified, and the entire article will be parsed after triggering.

Pull parsing: This method is a revision of the sax parsing. Android usually uses event-triggered parsing, but does not need to scan the entire file stream to find the desired part, parse that part to avoid the SAX parsing method. As long as the parsing is triggered, the whole article will be parsed, so it is simpler than the sax parsing and consumes less memory!

 

What the teacher said about learning: whether we need to know all the specific details. This is not necessary. As long as we can probably know this part of knowledge, we can probably know what it is when we encounter problems in development in the future, and focus on learning its core knowledge to get twice the result with half the effort, if you do not know the current scenarios of continuous operation, and blindly follow the video to learn the complex and direct view of the specific core technical points, the human brain will eliminate all useless items, it is estimated that I will forget it after I finish learning it!

The human brain is amazing. If you don't tell him what this knowledge can do, you will soon forget it. If you do not know the purpose of learning this article, you will learn more and forget it!

 

 

 

Related Article

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.