We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

how to read a specific record from xml file

Thread ID:




52184 Nov 23,2006 08:53 AM UTC ASP.NET Web Forms (Classic) 0
Tags: FAQ
Asked On November 23, 2006 08:53 AM UTC


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();


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


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon