Read xml files in c # and use the XmlDocument class. Example:
XmlDocument lXmlDocument = new XmlDocument (); -------------------------------------------------- create an object for reading xml files lXmlDocument
LXmlDocument. Load (lFileName); -------------------------------- required. You must load the file name before you can locate the file and open the file.
If (string. Compare (lXmlDocument. DocumentElement. Name, "BandConfig", true) = 0)
{--------------------------------- DocumentElement. Name indicates the node to be obtained. Here the root element mark is BandConfig.
--------------------------------- Read the XmlNode value of the subnode if it is correct.
Foreach (XmlNode node in lXmlDocument. DocumentElement) ------- use of XmlNode and DocumentElement
{---------------------------- All the child nodes in the xml file are traversed.
Int B = int. Parse (node. FirstChild. InnerText); --------- node. FirstChild. InnerText is used to obtain the value of the first element. It can also be value.
Color c = System. Drawing. Color. FromArgb (int. Parse (node. FirstChild. NextSibling. InnerText); --- brother node of the child node.
Float w = float. Parse (node. LastChild. InnerText );
MConfigs. Add (new BandConfigElement (B, c, w ));
}
Return true;
}
Else
{
Return false;
}