XmlDocument doc = new XmlDocument(); XmlNode docNode = doc.CreateXmlDeclaration("1.0", "UTF-8","yes"); doc.AppendChild(docNode); XmlNode Rule = doc.CreateElement("Rule"); XmlAttribute Ruletag = doc.CreateAttribute("name"); Ruletag.InnerText = "This Is My Rule"; Rule.Attributes.Append(Ruletag); doc.AppendChild(Rule); XmlNode Definition = doc.CreateElement("definition"); Rule.AppendChild(Definition); XmlNode code = doc.CreateElement("code"); XmlAttribute cname = doc.CreateAttribute("name"); cname.InnerText = "dynamicorderagent"; code.AppendChild(doc.CreateTextNode(txtVar.Text)); code.Attributes.Append(cname); Definition.AppendChild(code); //XmlNode offCondition = doc.CreateElement("offCondition"); // offCondition.AppendChild(doc.CreateTextNode( foreach (TabPage tp in tabControl3.TabPages) { foreach (Control ctrl in tp.Controls) { XmlNode eventScript = doc.CreateElement("eventScript"); XmlAttribute ename = doc.CreateAttribute("name"); XmlNode eXpres = doc.CreateElement("eventExpr"); XmlNode ecode = doc.CreateElement("code"); if (ctrl.GetType().Name == "Panel") { foreach (Control ctrl1 in ctrl.Controls) { if (ctrl1.GetType().Name == "TextBox") { TextBox tb = ctrl1 as TextBox; //if (tb.Name == "txtVar") // continue; if (tb.Name.StartsWith("Event")) { ename.InnerText = tp.Name; eXpres.AppendChild(doc.CreateTextNode(tp.Name)); } } } } if (ctrl.GetType().Name == "TextBox") { TextBox tb = ctrl as TextBox; if (tb.Name == "txtVar") continue; if (tb.Name.StartsWith("Code")) { ecode.InnerText = tb.Text; } eventScript.AppendChild(eXpres); eventScript.AppendChild(ecode); eventScript.Attributes.Append(ename); Definition.AppendChild(eventScript); } } } string Path = @"C:\Users\SristiSanskriti\Desktop\Office\FinalTemp.XML"; doc.Save(Path); MessageBox.Show("Created At :" + Path);
-<eventScript name=""> <eventExpr/> <code>if( EventExg > PreEventExg) { PreEventExg=EventExg; } else { out.writeln("Mcx-Sx update Error "); if(unhedgedMCX == 0 && unhedgedMCXSX == 0) currentStrategy.turnOff("Mcx-Sx update Error",true); } </code> </eventScript>
<eventScript name="value"> <eventExpr> value </eventExpr> <code> this value coming correct </code>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)