Hello all

i want to make application in c#
to read any xml file in tree

example the xml file like that


<?xml version="1.0"?>
<directory name="D:\ajsam">

<directory name="D:\ajsam\Muscle & Fitness">
	<directory name="D:\ajsam\Muscle & Fitness\aa">
		<file name="جديد.txt" size="12"/>
			<file name="Cover.jpg" size="8828"/>
				<file name="Thumbs.db" 

	<file name="Allthewarez.lnk" size="447"/>
			<file name="Allthewarez.nfo" 

				<file name="Cover.jpg" 

					<file name="Muscle & 

Fitness.avi" size="365424640"/>

<directory name="D:\ajsam\ABS">
		<file name="جديد.txt" size="12"/>
			<file name="Cover.jpg" size="8828"/>
				<file name="Thumbs.db" 



i want to read the attribute name and put it in the tree of

the c# application

i found code that read the xml file and put it in tree but it

read only the name of the tag (directory and file) but i want

to read the attribute
and other problem there if the name of any folder have char

of (&) it not run and if the text in any language other

english it appear ??????

this is the code can any one help me and make the changes on

it thank you.

this c# code i found

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;

namespace fileTreeXmlReader
    public partial class Form1 : Form
        public Form1()

        private void Form1_Load(object sender, EventArgs e)
            // Initialize the controls and the form.
            label1.Text = "File Path";
            label1.SetBounds(8, 8, 50, 20);
            //Application.StartupPath +
            textBox1.Text =  "c:\\ajsam.xml";
            textBox1.SetBounds(64, 8, 256, 20);
            button1.Text = "Populate the TreeView with XML";
            button1.SetBounds(8, 40, 200, 20);
            this.Text = "TreeView control from XML";
            this.Width = 536;
            this.Height = 768;
            treeView1.SetBounds(8, 72, 412, 564);


        private void treeView1_AfterSelect(object sender, 

TreeViewEventArgs e)


        private void button1_Click(object sender, EventArgs e)
                // SECTION 1. Create a DOM Document and load 

the XML data into it.
                XmlDocument dom = new XmlDocument();

                // SECTION 2. Initialize the TreeView control.
                    treeView1.Nodes.Add(new TreeNode

                TreeNode tNode = new TreeNode();
                tNode = treeView1.Nodes[0];

                // SECTION 3. Populate the TreeView with the 

DOM nodes.
                AddNode(dom.DocumentElement, tNode);
            catch (XmlException xmlEx)
            catch (Exception ex)
   private void AddNode(XmlNode inXmlNode, TreeNode 

         XmlNode xNode;
         TreeNode tNode;
         XmlNodeList nodeList;
         int i;

         // Loop through the XML nodes until the leaf is 

         // Add the nodes to the TreeView during the looping 

         if (inXmlNode.HasChildNodes)
            nodeList = inXmlNode.ChildNodes;
            for(i = 0; i<=nodeList.Count - 1; i++)
               xNode = inXmlNode.ChildNodes[i];
                   inTreeNode.Nodes.Add(new TreeNode

              // inXmlNode
               tNode = inTreeNode.Nodes[i];
               AddNode(xNode, tNode);
            // Here you need to pull the data from the XmlNode 

based on the
            // type of node, whether attribute values are 

required, and so forth.
            inTreeNode.Text = (inXmlNode.OuterXml).Trim();