TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Nbl Bz
NA
56
12.9k
get an XML file with all attributes in a treeview
Oct 9 2014 7:36 AM
Hello ,
am new in C# programmation , then im working on an application for XML file.
I want to read an XML file on a treeview, i have a code but he dont get all attributes for the node parent .
this is my function
void BuildNode(XmlNode xmlNode, TreeNode node)
{
if (xmlNode.HasChildNodes)
{
foreach (XmlNode childNode in xmlNode.ChildNodes)
{
var treeNode = new TreeNode(childNode.Name);
node.Nodes.Add(treeNode);
BuildNode(childNode, treeNode);
}
}
else
{
node.Text = (xmlNode.OuterXml).Trim();
}
}
then for my button to browse xml file :
/* var doc = new XmlDocument();
doc.Load(textBox1.Text);
// doc.Load(@"e:\\Test.xml");
treeView1.Nodes.Clear();
var rootNode = new TreeNode(doc.DocumentElement.Name);
treeView1.Nodes.Add(rootNode);
BuildNode(doc.DocumentElement, rootNode);
treeView1.ExpandAll();
Reply
Answers (
19
)
RegEx to find and replace a word
Creating an instance of a class