Rach Singh

Rach Singh

  • NA
  • 17
  • 0

How to use a class for xml related logic taking xml file "uri" as initializer.

Mar 5 2009 5:27 AM
Hi ,
i have a project in which i created two classes TreeDisplay(Form.cs) and MytreeNode class in same namespace.
TreeDisplay class contains all the GUI related stuff like Browse button textbox,label,progress bar and TReeView. I want the user to select a XML file  through browse button which will be displayed in textbox.The Xml file selected will be displayed in Treeview on winform.
Now i want to separate the GUI part from business logic(where i am creating treenode and adding nodes to tree)  thats why i created the MytreeNode class. I am passing the treeview and the string filename from the FileOpenDialogue in Browse button.
 i want to pass a Xml file name from one class to another class in same namespace using URI.i want to initialize with file path. i have passed the treeview object from GUI to my backhand class MytreeNode class.
But how to initialize with fie path? here is a part of code.
public class MytreeNodeClass
    {
        internal void initiatingTree(string nameofFile,TreeView treeView1)
        {
            try
            {
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(nameofFile);
                treeView1.Nodes.Clear();
                if (xmlDocument.DocumentElement != null)
                    if (true) treeView1.Nodes.Add(new TreeNode(xmlDocument.DocumentElement.Name));

Help me in putting up the right part of code at right place.
Thanks

Answers (1)