Tuesday, 29 December 2015

XML : Reading XML data into C# Winform Textbox through Iteration

I have an XML Document which bears the following structure.

  <root>    <parent_category_1>  <category_1_child_1> Child 1 Data </category_1_child_1>  <category_1_child_2> Child 2 Data </category_1_child_2>  <category_1_child_3> Child 3 Data </category_1_child_3>  </parent_category_1>    <parent_category_2>  <category_2_child_1> child 1 Data </child_1>  <child_2> child 2 Data </child_2>  <child_3> child 3 Data </child_3>  </parent_category_2>    </root>    

I am trying to populate these data into individuals Rich Textboxes on my Windows Form upon button click event. So I have around 20+ buttons and for every button click event it'll populate data into those rich 15-20 textboxes. ( The Data in these RTBs will be refreshed from XML file upon button click ). Every individual button will represent a parent and when the button is clicked , it'll load the value of child data from xml file into the corresponding textbox on the win form.

Currently I have to read every individual child node value based on it's name into the textboxes. It will not be efficient at all considering the amount of data. Blame my lack of knowledge but I am unable to locate a way to create one loop/iteration to get all these data populated. Some help or way to implement this would be highly appreciated.

No comments:

Post a Comment