When writing XML documents, you must follow some rules. However, these rules are usually very simple and easy to understand. Here we will describe these rules.
XML document version
The first row of the XML document is used to define the version of the XML used in this document. The XML> label in the following code defines the version of the XML document used to 1.0.
XML Version = '1.0'?> source code section of c-sharp corner code>
GDI Source Code Section of C-Sharp Corner Code>
XML element name
XML elements cannot contain spaces;
XML elements cannot begin with numbers or punctuation;
XML elements can contain letters, numbers, and other symbols;
Case Sensitive
Unlike HTML, XML is sensitive. Therefore, the
The XML parser does not parse this statement but gives an error message.
Root node
Each XML document must have a root node. In the above XML document,
Complete label
Each tab of XML must have a corresponding end tag. The code that has not ended the label is invalid. The following code contains an invalid XML tag:
Suitable order
Unlike HTML, XML tags cannot be placed casually. For example, the following code is correct in HTML, and is invalid in XML:
this is a section b> i>
The correct code should be like this:
this is a section i> b>
Space is also part of the XML documentation
Spaces are part of the XML document; and HTML is different, and in XML is displayed in the browser.
Attribute value must be included in a pair of double quotes
The attribute value must be placed in a pair of double quotes, otherwise it is invalid. E.g:
Source Code Section of C-Sharp Corner Code>
In the above code, C # is not included in the double quotes and is therefore invalid.