Learn how to create web pages familiar with XML syntax rules

Source: Internet
Author: User
The syntax of XML is simple and strict, and it is very easy to learn and apply. As a result, it is relatively easy to write software for reading and controlling XML. The example XML document of an XML document applies the self-describing and simple syntax .? Xmlversion = the syntax of XML is simple and strict, and it is very easy to learn and apply. As a result, it is relatively easy to write software for reading and controlling XML.

Example of an XML document

   The XML document applies the self-describing and simple syntax.

   
   
  
   Tove
    
  
   Jani
    
  
   Reminder
    Don't forget me this weekend!  
 

Line 2 of the document: XML declaration-defines the version of the XML scale that this document complies with. In this example, it is the version 1st, the ISO-8859-1 (Latin-1/West European) character set is applied.

The next line describes the root element of the document (like it was saying: 'This document is a note '):
The first line of the document is the root element (like saying "this document is a note "):

 
  
Line 3-6 of the document describes the four subnodes (to, from, heading, and body) of the root element ):
Tove
Jani
Reminder
Don't forget me this weekend!
The last line of the document is the end of the root element.

Can you see from this document that this is a note left by Ordm for Lin? Can we not admit that XML is a beautiful self-describing language?

All XML documents must have an end mark

   In XML documents, the ending tag is neglected and does not comply with the regulations.

In HTML documents, some elements can be unending tags. The following code is complete and justified in HTML:

This is a paragraph

This is another paragraph

However, the end mark must be included in the XML document, as shown in the following example:

This is a paragraph

This is another paragraph

 

   Be careful: You may have noticed that the first line in the above example does not end with the mark. This is not an error. Because the XML declaration is not part of the XML document, it is not an XML element and should not end with an ending mark.

XML tags are case sensitive.

   Unlike HTML, XML tags are case sensitive.

In XML, Mark And Mark Are two different tags.

Therefore, the start and end tags must be in the same case in the XML document.

 
  This is incorrect
   
 
  This is correct
 

All XML elements must be fairly included

   

   XML does not promise inaccurate nested inclusion.

In HTML, some inaccurate content is allowed. for example, the following code can be parsed by the browser:

This text is bold and italic

In XML, all elements must be accurately nested. the above code should be written as follows:

This text is bold and italic

All XML documents must have a root element.

   The first element in the XML document is the root element.

All XML documents must contain a separate tag, and all other elements must be nested in the root element. XML documents have only one root element.

All elements can have child elements. child elements must be accurately embedded in the parent element. the following code can be illustrated as follows:

     
        
   
    .....
       
    
  

Quotation marks ('') must be applied to attribute values''

   In XML, the attribute values of an element are not enclosed by quotation marks.

Like HTML, XML elements can also have attributes. The attributes of XML elements are displayed in pairs of names and values. The XML syntax specification requests the XML element property values must be enclosed in quotation marks. Please refer to the two examples below. The first is incorrect, and the second is accurate.

   
   
  
   Tove
    
  
   Jani
    
 

   
   
  
   Tove
    
  
   Jani
    
 

The error in the first document is that the attribute value is not quoted in quotation marks.

Accurate syntax: date = '2014/1/99'. inaccurate syntax: date = 12/11/99.

Apply XML, and the vacancy will be retained

   In XML documents, the vacant part is not automatically deleted by the parser.

   
This is different from HTML. In HTML, such a sentence:

'Hello my name is ordm' will be displayed as 'Hello my name is ordm ',

The HTML parser will take the initiative to remove the vacant part of the sentence.

The application XML, CR/LF is converted to LF

   XML application. new rows are always marked as LF(Line Feed, Line Feed ).

Do you know what a typewriter is? Well, typewriter was a specialized typing machine used in the last century. ^ & ^

After you have typed a line with a typewriter, you usually have to move the typing head to the left of the paper.

In the Windows Exploitation Program, the new line in the text is often identified as cr lf (carriage return, line feed, carriage return, line feed ). In Unix exploitation programs, the new line is often identified as LF. Some other applications only apply CR to express a new line.

Annotations in XML

The annotation syntax in XML is the same as that in HTML.

   

XML is nothing special.

XML really has nothing special to do. It's just plain text that is expanded with angle brackets. Software that compiles common text can also compile XML documents. However, in an XML-supporting exploitation program, XML tags often correspond to special controls. some tags may be visible, while some tags may not be displayed, there is no special control.


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.