C# xml Database Read and Write

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
16,060
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Oct 5, 2009

how to make a program that read and write an advanced(2 or more elements) xml (eXtensible Markup Language) database

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;
}

Category:

Education

Tags:

License:

Standard YouTube License

Link to this comment:

Share to:

Uploader Comments (blacklistnr1)

  • today i will show you how to type like a turtle in a notepad

  • @xlaFax Yeah, I was a bit slow

  • I think it's a good video, but if you can please copy and paste the code to here.

  • OK I'll post the code, tomorrow

  • can you please msg me the code the one in the comments is wrong

  • The code works for me

see all

All Comments (12)

Sign In or Sign Up now to post a comment!
  • and i can't rewriting to an xml file

  • tnks dudde fr exchanging the information .. all is already in work but i"m i have only one problem .. i can't see the xml data node writing in my labels

  • i am unable to continusly put or to make a database. it clears the value and then make it. i want to create a overall XML database. Kindly help me my email is nehul.splendit@gmail.com

    thanks for your nice tutorial

  • thanks, how to do it using datasets?

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more