Display hierarchical XML data using a DataGrid

I have an XML file like the one below

<root>
  <child1>
    <grandchild1>
       <greatgrandchild1>
       </greatgrandchild1>
       <greatgrandchild2>
       </greatgrandchild2>
       ...
    </grandchild1>
    <grandchild2>
    </grandchild2>
    <grandchild3>
    </grandchild3>
    ...
  </child1>
  <child2>
    <grandchild1>
    </grandchild1>
    <grandchild2>
    </grandchild2>
    <grandchild3>
    </grandchild3>
    ...
  </child2>
  <child3>
    <grandchild1>
    </grandchild1>
    <grandchild2>
    </grandchild2>
    <grandchild3>
    </grandchild3>
    ...
  </child3>
  ...
</root>

Each node child has a different name. I need to display this XML as follows:

Each child node is displayed as Expander. All the grandchildren of this child node are placed inside this expander. Each grandson and his children should be grouped and should have a background color. The next grandson and his children should have an alternative colored background.

All data has two columns. Therefore, the control selected to display this data must support multiple columns.

DataGrid. , . DataGrid. , , . .

+3
2

XML , - , XML, - DataSet (DataSet.ReadXML()).

DataSet DataTable .

+1

XML. , -. XML? :

<root>
  <child name="name1">
    <grandchild name="name11">
      <greatgrandchild name="name111"/>
      <greatgrandchild name="name112"/>
    </grandchild>
    <grandchild name="name12"/>
  </child>
  <child name="name2">
    <grandchild name="name21"/>
    <grandchild name="name22"/>
  </child>
</root>

, . xml- w3schools. .

XML, , , . XML- XML, xml , XmlDocument . xml, , , , xml .

, xml, datagrid listview XML.

0

Source: https://habr.com/ru/post/1712973/


All Articles