XML Overview:
: Extensible Markup Language
: XML is used to describe data
: XML is called Extensible Markup Language, which is used primarily to describe data
: XML nodes are case-sensitive, paired, and can be freely extended
Methods of manipulating XML (i)
1. Instantiate Document Object XMLDocument myXML =new XMLDocument (), parsing XML file class
2, Myxml.load ("Engineer.xml"); load the specified XML data
3, XmlNode engineer = myxml.documentelement; get root node
4, foreach (XmlNode node in engineer. ChildNodes) gets all the child nodes of the current node
{
Switch (node. Name) Current node name
{
Case "Name":
Console.WriteLine ("Name: {0}", node.) InnerText); The value of the current node
Break
Top down, row by line parsing
}
}
Ways to manipulate XML (ii)
: Traversing a child node under a child node through a double foreach loop
: Direct output through the name of the child node
TreeView Display Data (i)
TreeView Dynamic Add Node
Tree Menu Expansion Method: Control name. ExpandAll ();
To delete a node:
this. The name of the control. Selectednode.remove ();
To empty a node:
this. The name of the control. SelectedNode.Nodes.Clear ();//empties all child nodes under the node
this. The name of the control. Node.clear ();//empties all nodes in the TreeView control
The method of emptying the tree menu is often used to update the top of the tree menu method so that the node is not loaded repeatedly
Summarize:
TreeView is used to display information with hierarchies
The TreeView main attributes are nodes and SelectedNode
TreeNode the Node object that represents the TreeView
The Text property is used to set the text description of the node
The Tag property can set node-related information
Extensible Markup Language XML