C # Basic knowledge of the Ten
Written by Zhu Zhu, please specify from Zhu Zhu Homeland http://blog.csdn.net/zhgl7688
1. The data in the XML document contains an XML tree that consists primarily of nested elements, each of which has a name and contains data, and can contain other nested elements.
2. Elements are divided by the start and close labels, and any element contains data that must be between the start and close labels.
3. The XML document must have a root element to contain other elements. The space in the XML document is different from the HTML, and it is valid.
4, the XML attribute is the name/value of the pairing, it contains the elements of the additional metadata. The value part of the attribute must be enclosed in quotation marks, either single or double quotes.
5. LINQ to XML can be used in conjunction with XML in two ways: the first as a simplified XML operations API and the second using the LINQ Query tool.
6. The LINQ to XML API consists of a number of classes that represent XML tree components, common classes are: XElement, XAttribute, and XDocument.
7. Create an XML document using the constructors of XDocument and XElement. The first parameter is the name of the object, and the second and subsequent arguments contain the nodes of the XML tree, which can have any number of arguments.
8. The nodes method returns an object of type ienumerable<object>, and the returned type may be of a different type.
9. Elements method: Returns all child xelements with no parameters, and returns only the child xelements with name, using a single name parameter.
10. Element method: Returns the first child XElement node when no parameter is used, and returns the first child XElement with name when using a single name parameter.
11, the Operation Xml:add adds a new child node after the current node;
AddFirst adds a new child node before the current node;
Addbeforeself add a new node before the current node of the same level
Addafterself add a new node after the current node of the same level
Remove deletes the currently selected node and its contents
Removenodes Delete the currently selected XElement and its contents
SetElement Setting the contents of a node
Replacecontent replacing the contents of a node
12. XML attribute: Created with the XAttribute constructor, which has two parameters, the first specifies the attribute name, and the second specifies the value. Get the attribute value using the Attribute (attribute name) property, with the Attribute (attribute name). Remove removes the attribute.
13. Setattributevalue Method: Add an attribute or change the value of an attribute to the XML tree.
14. Xcomment generates comments consisting of the text between the <!-and the tokens. Example: Newxcomment ("This is a comment").
15, the XML declaration is generated by Xdeclaration. Example: Newxdeclaration ("1.0", "Utf-8", "yes").
16. Xprocessinginstruction is used to associate an XML document with a style sheet, which accepts two character parameters (targets and data strings).
17. Combining the LINQ XML API with LINQ query expressions produces a simple and powerful XML tree search.
Written by Zhu Zhu, please specify from Zhu Zhu Homeland http://blog.csdn.net/zhgl7688
C # Basic knowledge of the Ten