|
-
January 9th, 2012, 11:02 AM
#1
show data grid view of xml in C# form application
<?xml version="1.0" encoding="utf-8" ?>
<phonebook>
<phone-number category = "family_relatives">
<name> cathy </name>
<number type = "vodafone"> 02698456</number>
</phone-number>
<phone-number category = "office">
<name>MAPLE </name>
<number>051235 </number>
<address> MCIOEJAERJ</address>
</phone-number>
<phone-number category="peers">
<name>15vregtre </name>
<number>23154632165 </number>
<address>klgirmfgj </address>
<designation>klirglkfg </designation>
</phone-number>
</phonebook>
********************************************
1. How to display the xml to data grid view in C# form application?
2. How can we display type attribute in the grid view?
Also, the code to read the xml file is not working, it does not show any error but do not display any o/p. I can't debug it.
Can any one tell me the error
**********************************************
private void butLoad2_Click(object sender, EventArgs e)
{
XmlTextReader reader = new XmlTextReader("PhoneBookDirectory.xml");
XmlNodeType type;
while (reader.Read())
{
type = reader.NodeType;
if (type == XmlNodeType.Element)
{
if (reader.Name == "phonebook")
{
reader.Read();
textBox1.Text = reader.Value;
}
if (reader.Name == "phone-number")
{
reader.Read();
listBox1.Items.Add(reader.Value);
}
}
reader.Close();
}
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|