| | |
read xml file and display to many text box
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2007
Posts: 172
Reputation:
Solved Threads: 16
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);
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);
•
•
Join Date: Dec 2007
Posts: 3
Reputation:
Solved Threads: 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());
}
}
}
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());
}
}
}
![]() |
Similar Threads
- explorer.exe uses 99% CPU (Viruses, Spyware and other Nasties)
- trojans...now nothing opens and I get a paint can't open error (Viruses, Spyware and other Nasties)
Other Threads in the C# Forum
- Previous Thread: retreive data in textbox
- Next Thread: datagrid cell edit event
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access ado.net algorithm array barchart bitmap box broadcast buttons c# chat check checkbox class client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption enum event excel file files form format forms function gdi+ httpwebrequest image index input install java label list listbox listener login mandelbrot math mysql networking object operator oracle path photoshop picturebox pixelinversion post prime programming radians regex remote remoting resource richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view webbrowser windows winforms wpf xml





