how to read a specific record from xml file

Hello

I have a xml file and i want to display a particular record from xml file in text boxes and want to edit it.

here is my code

string xPath = "/CategoryCatalog/Category[@CategoryID='" + ID3 + "']";

xDoc = new XmlDocument();

xDoc.Load(Server.MapPath("Category.xml"));

Category = xDoc.SelectSingleNode(xPath);

string name = Category.Attributes["Name"].Value;

string description = Category.Attributes["Description"].Value;

string fileName = Category.Attributes["ImageExt"].Value;


txtCate_Name.Text = name;

txtDescription.Text = description;

ViewState["filename"] = fileName;

Image1.Src = serverPath + fileName;

lblMessage.Text = " " + fileName + "
" + "Note : IF u want this image then Ok Otherwise browse the file to update";
///////
but this is giving error that : Object reference not set to an instance of an object at these lines:

Category = xDoc.SelectSingleNode(xPath);

name = Category.Attributes["Name"].Value;

description = Category.Attributes["Description"].Value;

fileName = Category.Attributes["ImageExt"].Value;

please give me solution of this problem

many thanks in advance


Loader.
Up arrow icon