Although this is old post, I resolve like below:
/// <summary>
/// Exports a module to xml
/// </summary>
/// <param name="ModuleID"></param>
/// <returns></returns>
public string ExportModule(int moduleID) {
// constants
const string StartTagformat = "<{0}>";
const string EndTagformat = "</{0}>";
const string Tagformat = "<{0}>{1}</{0}>";
// init vars
PortalSettings portalSettings = PortalController.GetCurrentPortalSettings();
int tabID = portalSettings.ActiveTab.TabID;
ModuleController objController = new ModuleController();
ModuleInfo objModule = objController.GetModule(moduleID, tabID, false);
Hashtable objSettings = objController.GetTabModuleSettings(objModule.TabModuleID);
StringBuilder sbXml = new StringBuilder();
// start xml
sbXml.Appendformat(StartTagformat, RootElement);
// save all keys
foreach (Object key in objSettings.Keys) {
sbXml.Appendformat(Tagformat, Convert.ToString(key), XmlUtils.XMLEncode(Convert.ToString(objSettings[key])));
}
// end xml
sbXml.Appendformat(EndTagformat, RootElement);
// return xml
return sbXml.ToString();
}
hope helps.