XmlDocument doc = new XmlDocument();
doc.Load(path);
doc.Save(Console.Out);
foreach (XmlNode node in doc.DocumentElement)
{
string word_name = node.Attributes[0].Value;
string word_translation = node["name of node"].InnerText;
}
XmlDocument doc = new XmlDocument();
using (StreamReader streamReader = new StreamReader(path_name, Encoding.UTF8))
{
contents = streamReader.ReadToEnd();
}
doc.LoadXml(contents);
// Include this namespace
using System.Xml;
// Read an XML From file
XmlDocument doc = new XmlDocument();
doc.Load("c: emp.xml");
// Or from string
doc.LoadXml("<xml>something</xml>");
// you can find a node like this
XmlNode node = doc.DocumentElement.SelectSingleNode("/book/title");
// or
foreach(XmlNode node in doc.DocumentElement.ChildNodes){
string text = node.InnerText; //or loop through its children as well
}
// and you can read the text inside the node
string text = node.InnerText;
// or read the attribute (the ? there is checking if it's null or not)
string attr = node.Attributes["theattributename"]?.InnerText
/// Credit to Wolf5 and George D Girton