Foreword: The technology is changing, the good thing still remains unchanged! XML is one of those things. When you bring up XML, everyone is familiar with it, and you can see and hear about it everywhere. Although XML has been around for decades, how many people really master it? XML has been a fire with Ajax before. You can look back at the technical ajax,wpf,silverlight we've seen before ... and Ado.net,web Service ... XML is everywhere, is XML just a markup language? Just ask "have start tag, and end tag, case-insensitive" Is it? Do you know that HTML is actually a kind of XML? Few books can fully explain XML, Either to talk about it with ASP.net, or to talk about XML and other technologies, and I'm not an expert, I want to write XML-specific articles. Share My Learning results with you.
In this series will be a more comprehensive discussion of XML-related knowledge: For example, xpath,xslt,xsd ... And the whole series are interspersed with the application, I hope you pay attention!
The contents of this chapter are as follows:
Definition and purpose of XML
There are those elements and attributes in the XML, and how to use them to generate well-formed XML documents
Validating the validity of XML using a document type definition (DTD)
The concept of 1.XML
XML explicitly defines a method for structuring, describing, and exchanging data. XML differs from HTML in that XML is not formatted for data. For example, in HTML <body><p> tags, many of them just represent a display structure, which is not the data we want, and cannot be saved to the database. and the tags in HTML are very limited, and the meaning of these tags is very fixed, such as <p> is segmented, when you see, <p>23.4</p>, you do not know the meaning of this number, is to indicate the temperature or price. However, XML does target data, No format tags, and can achieve the data self-describing, label definition is very flexible, such as, <title>ceo</title>,<name>xiaoyang</name> We see the labels and we know what it means, and we can convert it to the corresponding database field (talk later). In general, XML is a data-formatted, meaningful, flexible markup language.
2.XML element
The core of an XML document is the element that is contained within the document. People who have used HTML, are aware of the concept of elements. XML elements are similar to the concepts of HTML elements. In terms of element naming, XML rules are more flexible than HTML, but XML does not allow loose structures such as HTML elements (in HTML, not all tags must start and end tags correspond). The start and end tags of all XML elements, as well as the case.
For example:
Code
1 2 <Title> 3 <body>
4 5 6 xiaoyang
7
The code snippet above is not a problem for HTML, but as an XML document there is a problem: 1.1: The Open <body> tag does not have a close tag (</body>),
Code
<title> <body>
xiaoyang
</body>
Summary: From the above <body> elements you can see that to close the tag, just make them have the same element name, and add a "/" to the front. All elements between the start and end tags of the <body> element become child nodes. Pay attention to <HR > elements are slightly different. If the element you are talking about does not contain data, it is called an "empty element",