Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading text between XML tags in C# 1

Status
Not open for further replies.
There are many ways.
Here is one:
Code:
XmlTextReader xmlreader = null;
string strlink=""; 
try
{
XmlTextReader xmlreader = new XmlTextReader("myfile.xml");
while (xmlreader.Read())
{
    switch (xmlreader.NodeType)
    {
     	case XmlNodeType.Element:
     	if (xmlreader.Name=="link") // found "link" tag
     	{
		strlink= xmlreader.Name;
		xmlreader.Close();
		xmlreader=null;
	}
	break;
   }
}
}
catch (Exception ex)
{
  string strError=ex.GetType() + ex.Message;
}

finally
{
        if (xmlreader!=null)
          xmlreader.Close();
}
obislavu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top