0

hi

Dear Friend

i an the new member. i have problem in the xml file. my idea for project write to xml file and read the xml file and display to many the textBox. could you help me.i want display each value to sprat textBox..i want only for the read

2
Contributors
3
Replies
6
Views
9 Years
Discussion Span
Last Post by yemen2007
0

Your question is not very determined
If you want to write/read data from an xml file

add this namespace using System.Data to your project then create a new DataSet

DataSet myDataSet = new DataSet();

then:

to write data within an xml file use
string filePath = @"put your file path here";
myDataSet.WriteXml(filePath);


add this namespace using System.Data to your project then create a new DataSet

DataSet myDataSet = new DataSet();

then:

to read data from an xml file use
string filePath = @"put your file path here";
myDataSet.ReadXml(filePath);

0

HI

want say thanks cause you reply. The I done the part for write xml bout the problem is I want read the xml file and display inn the many text box. I want show me or explain for me how I can display the data inside xml file to the text box.

0

hi
i done this code bout steel have problem can not diplay it in the text box

  try
        {
            string sStartupPath = Application.StartupPath;

            XmlTextReader obj =
                  new XmlTextReader(sStartupPath + @"selected.xml");
            string sName = "";
            while (obj.Read())
            {
                switch (obj.NodeType)
                {
                    case XmlNodeType.Element:
                        sName = obj.Name;
                        break;
                    case XmlNodeType.Text:
                        switch (sName)
                        {
                            case "SiteName":
                                textBox1.Text = obj.GetAttribute("SiteName");
                                break;
                            case "WebmasterName":
                                textBox2.Text = obj.GetAttribute("WebmasterName");
                                break;
                            case "WebmasterEmail":
                                textBox3.Text = obj.GetAttribute("WebmasterEmail");
                                break;
                            case "NumberPages":
                                comboBox1.Text = obj.GetAttribute("NumberPages");
                                break;
                            case "FristTemplate":
                                radioButton1.Text = obj.GetAttribute("FristTemplate");
                                break;
                            case "SecondTemplate":
                                radioButton2.Text = obj.GetAttribute("SecondTemplate");
                                break;
                        }
                        break;
                }
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
    }
}

Edited by pyTony: fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.