ASP.NET Code Migration Assistants

Microsoft provides several code migration assistants free of charge to help developers move their web applications to ASP.NET. Although these migration assistants do not make the conversion process completely automatic, they will speed up your project by automating some of the steps required for migration.

 

Code Migration Assistants

ASP to ASP.NET Migration Assistant (Beta Version)
PHP to ASP.NET Migration Assistant (Beta version)
JSP to ASP.NET Migration Assistant

C# function to get node value from xml file

Yesterday, I had written a function in C#, to get node value from a valid xml file. This was done by using XPATH query Navigation.

Sample XML file :
________________
<?xml version=”1.0″ ?>
<bookstore>
 <book>
  <title>The Autobiography of Benjamin Franklin</title>
  <author>
   <first-name>Benjamin</first-name>
   <last-name>Franklin</last-name>
  </author>
  <price>8.99</price>
  </book>
</bookstore>

C# Function :
_____________

/// <summary>
/// Gets value of specified Expression
/// </summary>
/// <param name=”sFileName”>FileName to be loaded</param>
/// <param name=”sSelectExpression”>Xpath query. This value is case sensitive</param>
/// <returns></returns>
public static string GetNodeValue(string sFileName,string sSelectExpression)
{
 
 string sRetVal = “”;
 // Read the XML document
 XPathDocument myXPathDocument = new XPathDocument(ConfigDir + sFileName);
 XPathNavigator myXPathNavigator = myXPathDocument.CreateNavigator();
 XPathNodeIterator myXPathNodeIterator  = myXPathNavigator.Select(sSelectExpression);
 while (myXPathNodeIterator.MoveNext())
 {
  //Console.WriteLine(“<” + myXPathNodeIterator.Current.Name + “> ” + myXPathNodeIterator.Current.Value);
  sRetVal = myXPathNodeIterator.Current.Value;
 }
 return sRetVal;  
}

Usage:
GetNodeValue(“<<XMLfileName>>”,”/bookstore/book/price”) will return 8.99