Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Hi Guys,

Interaction with XML files from WinForm Applications is always interesting. Well, here I need your suggestions to populate node in tree view control from XML file.
And please let me know, the best way to interact with XML file for Reading and Writing as well as searching for specific data.
Thanks in advance.

Regards,
Itz.Irsahd
Posted

hi Irshad, i hope this will help you.
Populate TreeView control using XML[^]
best of luck.
 
Share this answer
 
Well,
The scenario is here.
I've books information in xml file.
And the structure of file as below:
HTML
<catalog>
 <book>
  <title />
  <author />
  <genre />
  <price />
  .
  .
 </book>
</catalog>


And I need to get all the authors and genre of books under two groups (By Author, By Genre).
So, I figure this out by help of Google:
I load document via XElement.

C#
XElement doc = XElement.Load(SourcFile );

and use loop to add values of author (for example) under the Author Group.

C#
foreach (XElement author in doc.Descendants("author"))
 {
   NewNode = AuthorGroupNode.Nodes.Add(author.Value);
 }


So, that' the story. But in this solution there is one thing to improve which is repeated values if some books have same author.
It is next task to do.

Thanks for time.

Regards,
Itz.Irshad
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900