How to read oData feed (atom+xml) in Dynamics CRM 2011 Plugin?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Good Evening All,
I want to create a plugin to fetch data from contacts and store its fields in my custom entity. I am using oData query for that. Butwhen i load my stream an error occurs "Plugin: System.Xml.XmlException: An XML comment cannot contain --, and - cannot
be the last character. Line 2, position 43.Detail". Here is my code
.................
HttpWebResponse searchResponse = null;<br/>
XmlTextReader rdrResults = null;<br/>
<br/>
string strSearch = "https://MyDomainXRMServices/2011/OrganizationData.svc/ContactSet/";<br/>
HttpWebRequest searchRequest = (HttpWebRequest)WebRequest.Create(strSearch);<br/>
<br/>
tracingService.Trace("SeacrhRequest: == " + searchRequest);<br/>
searchRequest.Accept = "application/atom+xml";<br/>
searchRequest.ContentType = "application/atom+xml;type=entry";<br/>
//searchRequest.Accept = "text/xml";<br/>
searchResponse = (HttpWebResponse)searchRequest.GetResponse();<br/>
<br/>
Stream responseStream = searchResponse.GetResponseStream();<br/>
rdrResults = new XmlTextReader(responseStream);<br/>
tracingService.Trace("rdrResults: == " + rdrResults);<br/>
XmlDocument xmlResults = new XmlDocument();<br/>
xmlResults.Load(rdrResults); // error occurred here<br/>
XmlNodeList resultList = xmlResults.SelectNodes("feed/entry/content type/m:properties");<br/>
foreach (XmlNode resultNode in resultList)<br/>
{<br/>
xRow = dt.NewRow();<br/>
xRow["field"] = resultNode.SelectSingleNode("field").InnerText;<br/>
xRow["field"] = resultNode.SelectSingleNode("field").InnerText;<br/>
xRow["field"] = resultNode.SelectSingleNode("field").InnerText;<br/>
}
..........................
I am constantly searching for the solution on the web, but no luck. Please help me .. :(
Thank, <hr class="sig -- NMathur

View the full article
 
Back
Top