How often does the letter "m" occur in:
Q: SharePoint Designer Workflows read .XOML file programmically using c# I need to get list of all the workflows using a custom activity.
I visited a workflow using designer and have the name of the activity.
I just need to read that xoml file and see whether that file contains the name of the custom activity or not.
I am able to get the workflow associations for the lists but do not know how to read the xoml file.
PS: SoapXML property of workflowassociation is not giving me the desired result.

A: You can try following code:
public static string 
  GetXOMLFromWorkflowInstance(SPListItem item, Guid wfInstanceId)
  {
    SPWorkflow wf = new SPWorkflow(item, wfInstanceId);
    SPWorkflowAssociation assoc = 
      item.ParentList.WorkflowAssociations[wf.AssociationId];

    XmlDocument doc = new XmlDocument();
    doc.Load(new StringReader(assoc.SoapXml));

    XmlNode node = doc.SelectSingleNode("/WorkflowTemplate");
    XmlAttribute attribute = node.Attributes["Name"];
    string wfName = attribute.Value.Replace(" ", "%20");            
    string webRelativeFolder = "Workflows/" + wfName;            
    string xomlFileName = wfName + ".xoml";

    SPFolder wfFolder = assoc.ParentWeb.GetFolder(webRelativeFolder);
    SPFile xomlFile = wfFolder.Files[xomlFileName];

    doc = new XmlDocument();
    using (Stream xomlStream = xomlFile.OpenBinaryStream())
    {
      doc.Load(xomlStream);
    }
    return doc.OuterXml;
  }

http://blog.krichie.com/2011/07/05/programmatically-reading-sharepoint-designer-workflow-xoml-files-at-run-time/

user
The total number of "m"s in that passage is 51.
assistant