HI,
Just adding the Scott answer, if you still want to use RetrieveMultiple
Not sure whether it is what do you want,
You can use XmlElement Class
EntityCollection fxResult1 = _orgService.RetrieveMultiple(new FetchExpression(fetchXml));
// 4. create XML Document Object to put the set of fetchXML records
XmlDocument xml = new XmlDocument();
XmlDeclaration xmlDeclaration = xml.CreateXmlDeclaration("1.0", null, "yes");
XmlElement root = xml.CreateElement("accounts");
xml.InsertBefore(xmlDeclaration, xml.DocumentElement);
xml.AppendChild(root);
// 5. Foreach loop through the result and Build the XML node
foreach (var e in fxResult.Entities)
{
XmlElement child_root_table = xml.CreateElement("Table1");
root.AppendChild(child_root_table);
XmlElement child_name = xml.CreateElement("name");
child_name.InnerText = e.Attributes["name"].ToString();
child_root_table.AppendChild(child_name);
XmlElement child_accountid = xml.CreateElement("accountid");
child_accountid.InnerText = e.Attributes["accountid"].ToString();
child_root_table.AppendChild(child_accountid);
XmlElement child_accountnumber = xml.CreateElement("accountnumber");
child_accountnumber.InnerText = e.Attributes["accountnumber"].ToString();
child_root_table.AppendChild(child_accountnumber);
XmlElement child_creditonhold = xml.CreateElement("creditonhold");
child_creditonhold.InnerText = e.Attributes["creditonhold"].ToString();
child_root_table.AppendChild(child_creditonhold);
}
// 6. Convert to XML file and save in hard drive.
string fetchXmlOutput = xml.OuterXml;
StringReader xmlst = new StringReader(fetchXmlOutput);
XmlDocument XDoc = new XmlDocument();
XDoc.LoadXml(fetchXmlOutput.ToString());
XDoc.Save(@"c:\\fetchxml-records.xml");
source:
prabirchoudhury.wordpress.com/.../dynamics-crm-2011-fetchxml-result-convert-to-xml-file
Hope it helps.
Thank you.