Reading Data from XML

public string GetElementValue(string strElementName)
reader = new XmlTextReader(@”C:\Inetpub\wwwroot\NumberVerfication\NumberVerification.xml”);
Boolean flag = false;
string strElementValue = String.Empty;
while (reader.Read())
if (reader.LocalName == strElementName)
strElementValue = reader.Value;
flag = true;
if (flag == false)
return null;
return strElementValue;

Here i/p for themethod strElementName is the tag name in the xml for which the value has to be read.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a website or blog at

Up ↑

%d bloggers like this: