Wednesday, December 19, 2007

Get started using FetchXML

Ever want to get started using FetchXML?

Well use this simple method to retrieve a node list with the results.
By providing this method with any fetchxml query it will return the appropriate nodelist.

   static XmlNodeList GetFetchResult(string fetchXML)
{
CrmService service = new CrmService();
service.Credentials = new System.Net.NetworkCredential("CRMAdmin", "Pa$$w0rd", "ADVWORKS");
//DataSet ds = GetData("select * from systemuser ");
string fetch = fetchXML;
string ret = service.Fetch(fetch);
System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
xdoc.LoadXml(ret);
System.Xml.XmlNodeList list = xdoc.SelectNodes("resultset/result");
xdoc = null;
return list;

}


Have a great day!

Oshri Cohen


Labels: , , , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home