I am trying to populate a TreeView in C# from an XML file using XDocument (LINQ to XML) I tried using this link.
When I failed to understand how the code in the link works I just copied it to my project and changed the necessary variables but it returns strange result on the TreeView
The XML file that I am using is for making folders but the folders are easy to create because you can extract the path easily from the XML document.
Here is what the file looks like:
<?xml version="1.0" encoding="utf-8"?>
<dir name="After">
<dir name="Site Documents">
<dir name="02. External">
<dir name="1. Mechanical">
<dir name="01. Submittals">
<dir name="1. Sent" />
<dir name="2. Received" />
</dir>
<dir name="02. Drawings">
<dir name="1. Sent" />
<dir name="2. Received" />
</dir>
<dir name="03. MIR">
<dir name="1. Sent" />
<dir name="2. Received" />
</dir>
<dir name="04. IR">
<dir name="1. Sent" />
<dir name="2. Received" />
</dir>
<dir name="05. RFI">
<dir name="1. Sent" />
<dir name="2. Received" />
</dir>
<dir name="06. DFC">
<dir name="1. Sent" />
<dir name="2. Received" />
</dir>
<dir name="07. PVN">
<dir name="1. Sent" />
<dir name="2. Received" />
</dir>
</dir>
<dir name="2. Electrical">
<dir name="01. Submittals">
<dir name="1. Sent" />
<dir name="2. Received" />
</dir>
<dir name="02. Drawings">
<dir name="1. Sent" />
<dir name="2. Received" />
</dir>
<dir name="03. MIR">
<dir name="1. Sent" />
<dir name="2. Received" />
</dir>
<dir name="04. IR">
<dir name="1. Sent" />
<dir name="2. Received" />
</dir>
<dir name="05. RFI">
<dir name="1. Sent" />
<dir name="2. Received" />
</dir>
<dir name="06. DFC">
<dir name="1. Sent" />
<dir name="2. Received" />
</dir>
<dir name="07. PVN">
<dir name="1. Sent" />
<dir name="2. Received" />
</dir>
</dir>
</dir>
<dir name="03. Internal">
<dir name="01. PR">
<dir name="1. MECH">
</dir>
<dir name="2. ELEC" />
</dir>
<dir name="02. PO">
</dir>
<dir name="03. SRF">
</dir>
<dir name="04. RMR" />
</dir>
</dir>
</dir>
The result in the treeview appears as:

