C# xml Database Read and Write

Published: 05 October 2009
on channel: blacklistnr1
33,236
14

how to make a program that reads and writes an "advanced"(2 or more elements) xml database

Song:3D Remedy - Here is my Heart


code for the write part:

string sStartupPath = Application.StartupPath;
XmlTextWriter objXmlTextWriter =
new XmlTextWriter(sStartupPath + @"\selected.xml",null);
objXmlTextWriter.WriteStartElement("MySelectedValues");
objXmlTextWriter.WriteStartElement("ID1");
objXmlTextWriter.WriteString(string);
objXmlTextWriter.WriteEndElement();
objXmlTextWriter.WriteStartElement("ID2");
objXmlTextWriter.WriteString(string);
objXmlTextWriter.WriteEndElement();
objXmlTextWriter.WriteEndElement();
objXmlTextWriter.Flush();
objXmlTextWriter.Close();

and for the read part:
doca = new XPathDocument(Application.StartupPath + @"\selected.xml");
nav = doca.CreateNavigator();
expr = nav.Compile("/MySelectedValues");
iterator = nav.Select(expr);
while(iterator.MoveNext())
{
XPathNavigator nav2 = iterator.Current.Clone();
nav2.MoveToFirstChild();
string s1 = nav2.Value.ToString();
nav2.MoveToNext()
string s2 = nav2.Value.ToString;
}


On this page of the site you can watch the video online C# xml Database Read and Write with a duration of hours minute second in good quality, which was uploaded by the user blacklistnr1 05 October 2009, share the link with friends and acquaintances, this video has already been watched 33,236 times on youtube and it was liked by 14 viewers. Enjoy your viewing!