# [.net] XML

## Recommended Posts

Cybrosys    186
This has probably already been discussed and i've tried googling for any Usefull tutorials or piece of information but i'm coming up short. All i'd like to know is how to create an Xml document properly using XmlDocument and then reading it properly and smart using for example XmlNodeList.. GetNodes...("SearchEntries")... for each XmlNode in... A smart solution. But i can't even create a document, root node problems, this and that, 500 different Create* functions and no propper tutorial or information... let's just say it's frustrating ;) Edit: Phew, finally got some results hehe
XmlDocument xDoc = new XmlDocument();

try
{

XmlElement entry = xDoc.CreateElement("Entry");

XmlAttribute nameAttrib = xDoc.CreateAttribute("name");
XmlAttribute pathAttrib = xDoc.CreateAttribute("path");

entry.Attributes.Append(nameAttrib);
entry.Attributes.Append(pathAttrib);

xDoc.DocumentElement.AppendChild(entry);

xDoc.Save("myXmlFile.xml");
}
catch (XmlException e)
{
Console.WriteLine(e.Message);
}

[Edited by - Cybrosys on July 18, 2005 6:34:04 PM]