Hello, this is in reference to a question asked earlier. Here is the complete code and it's giving me an error:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Xml;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.IO;
namespace LoadXMLtreeDisplay
{
public partial class TreeDisplay : Form
{
public string Filename
{
get { return filename; }
}
protected string filename;
public TreeDisplay()
{
InitializeComponent();
this.Text = "Tree View of XML File";//Form Title.
}
private void treeDocLoadMethod(string nameofFile)
{
XmlDocument xdoc = new XmlDocument();
xdoc.Load(nameofFile);
this.treeView1.Nodes.Clear();
this.treeView1.Nodes.Add(new TreeNode(xdoc.DocumentElement.Name));
TreeNode tNodeObj = new TreeNode();
tNodeObj = this.treeView1.Nodes[0];
XmlNode xNode = xdoc.DocumentElement;
AddingNodesToTree(tNodeObj, xNode);
treeView1.Nodes[0].Expand();
treeView1.CollapseAll();
}//treeDocLoadMethod
private void AddingNodesToTree(refXmlNode xnode,TreeNode tnode)
{
TreeNode subNode = tnode.Add(xnode.Name);
subNode.Tag = xnode;
foreach (XmlNode subElement in xnode.ChildNodes)
{
AddingNodesToTree(ref subElement, ref subNode);
}
}
private void treeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
{ listBox1.Items.Clear();
TreeNode currentNode = e.Node;
XmlElement currentElement = (XmlElement)currentNode.Tag;
XmlAttributeCollection attCol = currentElement.Attributes;
foreach (XmlAttribute xmlatt in attCol)
{
listBox1.Items.Show(xmlatt);
}
}
//Rest of the code is for winform display(various buttons and boxes)
}
}
After compiling this I am getting the error:
Expected class, delegate, enum, interface, or struct Type or namespace definition, or end-of-file expected
Please could you tell me what's the possible source of error and how to rectify it? I am a newbie in C#