Advertisement Jump to content
Sign in to follow this  
Cybrosys

[.net] XML

This topic is 4930 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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!