using System.Xml.Serialization;
public static void Main()
var classtextxml ="<AUMDashboard specialaccess='false' search='true' readonly='false' top='false' table='CONTACTBENEFIT_AUMDASHBOARD_ALIAS1' data-object='cdsDef'><AssetContact1 type='integer' search='true' readonly='false' col='AUM_ALIAS1_OtherNo'/><AssetContact2 type='integer' search='true' readonly='false' col='AUM_ALIAS1_OtherNo'/><AssetContact3 type='integer' search='true' readonly='false' col='AUM_ALIAS1_OtherNo'/><AssetContactPer1 type='double' search='true' readonly='false' col='AUM_ALIAS1_OtherPrem'/><AssetContactPer2 type='double' search='true' readonly='false' col='AUM_ALIAS1_OtherPrem'/><AssetContactPer3 type='double' search='true' readonly='false' col='AUM_ALIAS1_OtherPrem'/><Assets1 type='double' search='true' readonly='false' col='AUM_ALIAS1_CrtillPrem'/><Assets2 type='double' search='true' readonly='false' col='AUM_ALIAS1_CrtillPrem'/><Assets3 type='double' search='true' readonly='false' col='AUM_ALIAS1_CrtillPrem'/><AssetsPer1 type='double' search='true' readonly='false' col='AUM_ALIAS1_CrtillVen'/><AssetsPer2 type='double' search='true' readonly='false' col='AUM_ALIAS1_CrtillVen'/><AssetsPer3 type='double' search='true' readonly='false' col='AUM_ALIAS1_CrtillVen'/><AssetsPerContact1 type='double' search='true' readonly='false' col='AUM_ALIAS1_CTDCost'/><AssetsPerContact2 type='double' search='true' readonly='false' col='AUM_ALIAS1_CTDCost'/><AssetsPerContact3 type='double' search='true' readonly='false' col='AUM_ALIAS1_CTDCost'/><AssetsPerContactPer1 type='double' search='true' readonly='false' col='AUM_ALIAS1_CTDValue'/><AssetsPerContactPer2 type='double' search='true' readonly='false' col='AUM_ALIAS1_CTDValue'/><AssetsPerContactPer3 type='double' search='true' readonly='false' col='AUM_ALIAS1_CTDValue'/><BondAsset1 type='double' search='true' readonly='false' col='AUM_ALIAS1_BondValue'/><BondAsset2 type='double' search='true' readonly='false' col='AUM_ALIAS1_BondValue'/><BondAsset3 type='double' search='true' readonly='false' col='AUM_ALIAS1_BondValue'/><BondAssetPer1 type='double' search='true' readonly='false' col='AUM_ALIAS1_BondCost'/><BondAssetPer2 type='double' search='true' readonly='false' col='AUM_ALIAS1_BondCost'/><BondAssetPer3 type='double' search='true' readonly='false' col='AUM_ALIAS1_BondCost'/><Last180Days1 type='integer' search='true' readonly='false' col='AUM_ALIAS1_ULNo'/><Last180Days2 type='integer' search='true' readonly='false' col='AUM_ALIAS1_ULNo'/><Last180Days3 type='integer' search='true' readonly='false' col='AUM_ALIAS1_ULNo'/><Last180DaysPer1 type='double' search='true' readonly='false' col='AUM_ALIAS1_OtherDebt'/><Last180DaysPer2 type='double' search='true' readonly='false' col='AUM_ALIAS1_OtherDebt'/><Last180DaysPer3 type='double' search='true' readonly='false' col='AUM_ALIAS1_OtherDebt'/><Last30Days1 type='integer' search='true' readonly='false' col='AUM_ALIAS1_TermNo'/><Last30Days2 type='integer' search='true' readonly='false' col='AUM_ALIAS1_TermNo'/><Last30Days3 type='integer' search='true' readonly='false' col='AUM_ALIAS1_TermNo'/><Last30DaysPer1 type='double' search='true' readonly='false' col='AUM_ALIAS1_PPValue'/><Last30DaysPer2 type='double' search='true' readonly='false' col='AUM_ALIAS1_PPValue'/><Last30DaysPer3 type='double' search='true' readonly='false' col='AUM_ALIAS1_PPValue'/><Last365Days1 type='integer' search='true' readonly='false' col='AUM_ALIAS1_LifeNo'/><Last365Days2 type='integer' search='true' readonly='false' col='AUM_ALIAS1_LifeNo'/><Last365Days3 type='integer' search='true' readonly='false' col='AUM_ALIAS1_LifeNo'/><Last365DaysPer1 type='double' search='true' readonly='false' col='AUM_ALIAS1_BankCost'/><Last365DaysPer2 type='double' search='true' readonly='false' col='AUM_ALIAS1_BankCost'/><Last365DaysPer3 type='double' search='true' readonly='false' col='AUM_ALIAS1_BankCost'/><Last90Days1 type='integer' search='true' readonly='false' col='AUM_ALIAS1_PermNo'/><Last90Days2 type='integer' search='true' readonly='false' col='AUM_ALIAS1_PermNo'/><Last90Days3 type='integer' search='true' readonly='false' col='AUM_ALIAS1_PermNo'/><Last90DaysPer1 type='double' search='true' readonly='false' col='AUM_ALIAS1_REDebt'/><Last90DaysPer2 type='double' search='true' readonly='false' col='AUM_ALIAS1_REDebt'/><Last90DaysPer3 type='double' search='true' readonly='false' col='AUM_ALIAS1_REDebt'/><MFAsset1 type='double' search='true' readonly='false' col='AUM_ALIAS1_MfValue'/><MFAsset2 type='double' search='true' readonly='false' col='AUM_ALIAS1_MfValue'/><MFAsset3 type='double' search='true' readonly='false' col='AUM_ALIAS1_MfValue'/><MFAssetPer1 type='double' search='true' readonly='false' col='AUM_ALIAS1_MfCost'/><MFAssetPer2 type='double' search='true' readonly='false' col='AUM_ALIAS1_MfCost'/><MFAssetPer3 type='double' search='true' readonly='false' col='AUM_ALIAS1_MfCost'/><NoContactWithDI1 type='integer' search='true' readonly='false' col='AUM_ALIAS1_OfficeID'/><NoContactWithDI2 type='integer' search='true' readonly='false' col='AUM_ALIAS1_OfficeID'/><NoContactWithDI3 type='integer' search='true' readonly='false' col='AUM_ALIAS1_OfficeID'/><NoContactWithDIPer1 type='double' search='true' readonly='false' col='AUM_ALIAS1_DIPrem'/><NoContactWithDIPer2 type='double' search='true' readonly='false' col='AUM_ALIAS1_DIPrem'/><NoContactWithDIPer3 type='double' search='true' readonly='false' col='AUM_ALIAS1_DIPrem'/><NoContactWithLI1 type='integer' search='true' readonly='false' col='AUM_ALIAS1_ContactID'/><NoContactWithLI2 type='integer' search='true' readonly='false' col='AUM_ALIAS1_ContactID'/><NoContactWithLI3 type='integer' search='true' readonly='false' col='AUM_ALIAS1_ContactID'/><NoContactWithLIPer1 type='double' search='true' readonly='false' col='AUM_ALIAS1_LifePerm'/><NoContactWithLIPer2 type='double' search='true' readonly='false' col='AUM_ALIAS1_LifePerm'/><NoContactWithLIPer3 type='double' search='true' readonly='false' col='AUM_ALIAS1_LifePerm'/><StockAsset1 type='double' search='true' readonly='false' col='AUM_ALIAS1_StockValue'/><StockAsset2 type='double' search='true' readonly='false' col='AUM_ALIAS1_StockValue'/><StockAsset3 type='double' search='true' readonly='false' col='AUM_ALIAS1_StockValue'/><StockAssetPer1 type='double' search='true' readonly='false' col='AUM_ALIAS1_StockCost'/><StockAssetPer2 type='double' search='true' readonly='false' col='AUM_ALIAS1_StockCost'/><StockAssetPer3 type='double' search='true' readonly='false' col='AUM_ALIAS1_StockCost'/><VAAsset1 type='double' search='true' readonly='false' col='AUM_ALIAS1_VaValue'/><VAAsset2 type='double' search='true' readonly='false' col='AUM_ALIAS1_VaValue'/><VAAsset3 type='double' search='true' readonly='false' col='AUM_ALIAS1_VaValue'/><VAAssetPer1 type='double' search='true' readonly='false' col='AUM_ALIAS1_VaCost'/><VAAssetPer2 type='double' search='true' readonly='false' col='AUM_ALIAS1_VaCost'/><VAAssetPer3 type='double' search='true' readonly='false' col='AUM_ALIAS1_VaCost'/></AUMDashboard>";
var classtxt = ClassCreatorUtility.textOfClass(classtextxml);
Console.WriteLine(classtxt);
public static class ClassCreatorUtility
public static string textOfClass(string xml)
var classDefinition = string.Empty;
XmlDocument xmldoc = new XmlDocument();
var xmlObject = xmldoc.SelectNodes("*");
foreach (XmlNode node in xmlObject)
classDefinition = string.Format("[XmlRoot(\"{0}\")]{1}public class {2}", node.Name, Environment.NewLine, node.Name);
classDefinition += "{" + Environment.NewLine;
foreach (XmlNode properties in node.ChildNodes)
var custPropType = string.Empty;
var custPropName = string.Empty;
var className = string.Empty;
if (properties.Attributes["type"] != null)
custPropType = properties.Attributes["type"].Value;
custPropType = "DateTime";
custPropType = "DateTime";
custPropType = properties.Attributes["obj"].Value;
className = properties.Attributes["obj"].Value;
custPropType = string.Format("List<{0}>",properties.Attributes["obj"].Value);
else if (properties.Attributes["obj"] != null)
custPropType = properties.Attributes["obj"].Value;
if (properties.Attributes["ReferredById"] != null || properties.Attributes["ReferredByObj"] != null)
custPropName = properties.Attributes["col"].Value;
custPropName = properties.Name;
if (custPropName.Equals(custPropType))
classDefinition += string.Format("[XmlElement(\"{0}\", typeof({0}))]{1}", custPropName, Environment.NewLine);
classDefinition += string.Format("public {0} {1} ", custPropType, custPropName);
classDefinition += "{ get; set; }" + Environment.NewLine;
else if(custPropType.Contains("List")){
classDefinition += string.Format("[XmlElement(\"{0}\", typeof({1}))]{2}", custPropName, className, Environment.NewLine);
classDefinition += string.Format("public {0} {1} ", custPropType, custPropName);
classDefinition += "{ get; set; }" + Environment.NewLine;
classDefinition += string.Format("[XmlElement(\"{0}\")]{1}", custPropName, Environment.NewLine);
classDefinition += string.Format("public {0} {1} ", custPropType, custPropName);
classDefinition += "{ get; set; }" + Environment.NewLine;