Sign in to follow this  

[.net] XML

This topic is 4534 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
			{
				xDoc.LoadXml("<SearchEntries></SearchEntries>");
				

				XmlElement entry = xDoc.CreateElement("Entry");
				
				XmlAttribute nameAttrib = xDoc.CreateAttribute("name");
				XmlAttribute linkAttrib = xDoc.CreateAttribute("link");
				XmlAttribute pathAttrib = xDoc.CreateAttribute("path");

				nameAttrib.InnerText = "Google";
				linkAttrib.InnerText = "http://www.google.com";
				pathAttrib.InnerText = "http://www.google.com/?q=";

				entry.Attributes.Append(nameAttrib);
				entry.Attributes.Append(linkAttrib);
				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]

Share this post


Link to post
Share on other sites

This topic is 4534 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this