public XmlDocument GenerateXML() { XmlDataDocument doc = new XmlDataDocument(); XmlElement LTS = doc.CreateElement(Parsing.LTS_NODE_NAME); doc.AppendChild(LTS); XmlElement declar = doc.CreateElement(Parsing.DECLARATION_NODE_NAME); declar.InnerText = Declaration; LTS.AppendChild(declar); XmlElement process = doc.CreateElement(Parsing.PROCESSES_NODE_NAME); foreach (TACanvas canvas in Processes) { process.AppendChild(canvas.WriteToXml(doc)); } LTS.AppendChild(process); XmlElement properties = doc.CreateElement(Parsing.PROPERTIES_NODE_NAME.Replace(" ", "_")); foreach (TACanvas canvas in Properties) { properties.AppendChild(canvas.WriteToXml(doc)); } LTS.AppendChild(properties); return(doc); }
public XmlDocument GenerateXML() { XmlDataDocument doc = new XmlDataDocument(); XmlElement UmlModel = doc.CreateElement(Parsing.UML_MODEL_NODE_NAME); doc.AppendChild(UmlModel); XmlElement assertion = doc.CreateElement(Parsing.ASSERTION_NODE_NAME); assertion.InnerText = this.Assertion; UmlModel.AppendChild(assertion); XmlElement diagrams = doc.CreateElement(Parsing.DIAGRAMS_NODE_NAME); foreach (var diagram in Diagrams) { XmlElement diagramTag = doc.CreateElement(Parsing.DIAGRAM_TAG); XmlElement diagramName = doc.CreateElement(Parsing.DIAGRAM_NAME); diagramName.InnerText = diagram.Key; diagramTag.AppendChild(diagramName); XmlElement xmiContent = doc.CreateElement(Parsing.DIAGRAM_XMI_CONTENT); xmiContent.InnerText = diagram.Value.XmiContent; diagramTag.AppendChild(xmiContent); diagrams.AppendChild(diagramTag); } UmlModel.AppendChild(diagrams); return(doc); }
public XmlDocument GenerateXML() { XmlDataDocument doc = new XmlDataDocument(); XmlElement BPEL = doc.CreateElement(Parsing.BPEL_NODE_NAME); doc.AppendChild(BPEL); XmlElement assertion = doc.CreateElement(Parsing.ASSERTION_NODE_NAME); assertion.InnerText = Assertion; BPEL.AppendChild(assertion); if (PathContentMap.Count > 0) { XmlElement files = doc.CreateElement(Parsing.FILES_NODE_NAME); foreach (KeyValuePair <string, string> pair in PathContentMap) { XmlElement file = doc.CreateElement(Parsing.FILE_NODE_NAME); file.SetAttribute(Parsing.PATH_ATTR_NODE_NAME, pair.Key); if (!string.IsNullOrEmpty(pair.Value.Trim())) { file.InnerText = pair.Value; } files.AppendChild(file); } BPEL.AppendChild(files); } return(doc); }
/// <summary> /// 轉回 DAL 用 Content /// </summary> /// <param name="data"></param> /// <returns></returns> public void SetContentData(Dictionary <string, StudBatchUpdateRecContentEntity> data) { XmlElement retValue = new XmlDocument().CreateElement("Content"); Dictionary <string, List <StudBatchUpdateRecContentEntity> > ByGradeYear = new Dictionary <string, List <StudBatchUpdateRecContentEntity> >(); foreach (StudBatchUpdateRecContentEntity sburce in data.Values) { string strGRYear; if (string.IsNullOrEmpty(sburce.GetGradeYear())) { strGRYear = " "; } else { strGRYear = sburce.GetGradeYear(); } if (ByGradeYear.ContainsKey(strGRYear)) { ByGradeYear[strGRYear].Add(sburce); } else { List <StudBatchUpdateRecContentEntity> list = new List <StudBatchUpdateRecContentEntity>(); list.Add(sburce); ByGradeYear.Add(strGRYear, list); } // 清除原 XML UpdateBatchRec.Content.RemoveAll(); XmlElement elemRoot = new XmlDocument().CreateElement("異動名冊"); elemRoot.SetAttribute("學年度", SchoolYear + ""); elemRoot.SetAttribute("學期", Semester + ""); elemRoot.SetAttribute("學校名稱", SchoolName); elemRoot.SetAttribute("學校代號", SchoolCode); elemRoot.SetAttribute("類別", DocType.ToString()); foreach (KeyValuePair <string, List <StudBatchUpdateRecContentEntity> > val in ByGradeYear) { XmlElement elemGrdYear = new XmlDataDocument().CreateElement("清單"); elemGrdYear.SetAttribute("年級", val.Key); elemGrdYear.SetAttribute("科別", ""); foreach (StudBatchUpdateRecContentEntity sburce1 in val.Value) { XmlElement xe = elemGrdYear.OwnerDocument.ImportNode(sburce1.GetXmlData(), true) as XmlElement; elemGrdYear.AppendChild(xe); } XmlElement XmlRootChild = elemRoot.OwnerDocument.ImportNode(elemGrdYear, true) as XmlElement; elemRoot.AppendChild(XmlRootChild); } XmlElement elemRot = UpdateBatchRec.Content.OwnerDocument.ImportNode(elemRoot, true) as XmlElement; UpdateBatchRec.Content.AppendChild(elemRot); } }
public static void InitLogger() { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); startTime = DateTime.Now; times = new List <DateTime>(); fpss = new List <int>(1000); stopwatches = new List <Stopwatch>(); doc = new XmlDataDocument(); doc.CreateXmlDeclaration("1.0", "UTF-8", "yes"); dbgDoc = new XmlDataDocument(); dbgDoc.CreateXmlDeclaration("1.0", "UTF-8", "yes"); XmlElement html = doc.CreateElement("html"); XmlElement head = doc.CreateElement("head"); XmlElement link = doc.CreateElement("link"); XmlAttribute type = doc.CreateAttribute("type"); type.InnerText = "text/css"; link.Attributes.Append(type); XmlAttribute rel = doc.CreateAttribute("rel"); rel.InnerText = "Stylesheet"; link.Attributes.Append(rel); XmlAttribute href = doc.CreateAttribute("href"); href.InnerText = "logging.css"; link.Attributes.Append(href); head.AppendChild(link); html.AppendChild(head); XmlElement body = doc.CreateElement("body"); XmlElement text = doc.CreateElement("div"); text.InnerXml = "Logger verze 0.3; cas zacatku: " + startTime.ToString(); body.AppendChild(text); html.AppendChild(body); doc.AppendChild(html); dbgDoc = (XmlDataDocument)doc.CloneNode(true); bodyNode = doc.GetElementsByTagName("body")[0]; dbgBodyNode = dbgDoc.GetElementsByTagName("body")[0]; //Save(); bInitialized = true; Console.WriteLine("Logger spusten"); AddError("test"); }
public void NewInstance() { XmlDataDocument doc = new XmlDataDocument(); AssertDataSet("#1", doc.DataSet, "NewDataSet", 0, 0); Assert.IsFalse(doc.DataSet.EnforceConstraints); XmlElement el = doc.CreateElement("TEST"); AssertDataSet("#2", doc.DataSet, "NewDataSet", 0, 0); Assert.IsNull(doc.GetRowFromElement(el)); doc.AppendChild(el); AssertDataSet("#3", doc.DataSet, "NewDataSet", 0, 0); DataSet ds = new DataSet(); doc = new XmlDataDocument(ds); Assert.IsTrue(doc.DataSet.EnforceConstraints); }
public XmlDocument GenerateXML() { XmlDataDocument doc = new XmlDataDocument(); XmlElement PddlModel = doc.CreateElement(Parsing.PDDL_MODEL_NODE_NAME); doc.AppendChild(PddlModel); XmlElement domain = doc.CreateElement(Parsing.DOMAIN_NODE_NAME); XmlElement dFileName = doc.CreateElement(Parsing.PDDL_FILE_NAME_TAG); dFileName.InnerText = Domain != null ? this.Domain.Name : " "; domain.AppendChild(dFileName); XmlElement dPath = doc.CreateElement(Parsing.PDDL_FILE_PATH_TAG); dPath.InnerText = Domain != null ? this.Domain.FilePath : " "; domain.AppendChild(dPath); PddlModel.AppendChild(domain); XmlElement diagrams = doc.CreateElement(Parsing.PROBLEMS_NODE_NAME); foreach (var problem in this.Problems) { XmlElement problemTag = doc.CreateElement(Parsing.PROBLEM_NAME); XmlElement problemName = doc.CreateElement(Parsing.PDDL_FILE_NAME_TAG); problemName.InnerText = problem.Key; problemTag.AppendChild(problemName); XmlElement problemPath = doc.CreateElement(Parsing.PDDL_FILE_PATH_TAG); problemPath.InnerText = problem.Value.FilePath; problemTag.AppendChild(problemPath); diagrams.AppendChild(problemTag); } PddlModel.AppendChild(diagrams); return(doc); }
public void CreateXml(DataSet dataset_for_index_doc, DataSet dataset_for_folder, string indexing, string fullPath, string filename, SqlConnection connection, string folderID, string docID) { string temp_string = System.IO.Path.GetExtension(filename); string output_filename = filename.Replace(temp_string, ".xml"); string temp_fullpath = string.Format("{0}\\{1}", fullPath, output_filename); //String SQLCommand = " select * from obj where parent_id =" + indexing ; DataRow[] indexRow = dataset_for_index_doc.Tables[0].Select("DocID = " + docID); XmlDataDocument doc = new XmlDataDocument(); XmlDeclaration xmlDeclaration = doc.CreateXmlDeclaration("1.0", "UTF-8", null); XmlElement root = doc.DocumentElement; doc.InsertBefore(xmlDeclaration, root); DataRow[] r = dataset_for_folder.Tables[0].Select("folderID = " + folderID); string temp_index_name = r[0].ItemArray[0].ToString().Replace(" ", ""); XmlElement element1 = doc.CreateElement(string.Empty, temp_index_name, string.Empty); doc.AppendChild(element1); //Create an element representing the first customer record. //foreach (DataRow row in ds.Tables[0].Rows) //{ // string temp_index_name1 = row.ItemArray[3].ToString().Replace(" ", ""); // XmlElement element2 = doc.CreateElement(string.Empty, temp_index_name1, string.Empty); // XmlText text1 = doc.CreateTextNode(row.ItemArray[3].ToString()); // element2.AppendChild(text1); // element1.AppendChild(element2); //} foreach (DataRow index in indexRow) { string temp_index_name1 = index.ItemArray[4].ToString().Replace(" ", ""); XmlElement element2 = doc.CreateElement(string.Empty, temp_index_name1, string.Empty); XmlText text1 = doc.CreateTextNode(index.ItemArray[3].ToString()); element2.AppendChild(text1); element1.AppendChild(element2); } doc.Save(temp_fullpath); }
private void save() { XmlDataDocument xml_doc = new XmlDataDocument(); XmlNode root = xml_doc.CreateElement("vocab"); foreach (LessonNode l in LessonStore) { XmlNode lesson = xml_doc.CreateElement("lesson"); XmlAttribute a_id = xml_doc.CreateAttribute("id"); XmlAttribute a_description = xml_doc.CreateAttribute("description"); a_id.Value = l.Id.ToString(); a_description.Value = l.Description; lesson.Attributes.Append(a_id); lesson.Attributes.Append(a_description); foreach (PairNode p in l.PairStore) { XmlNode pair = xml_doc.CreateElement("pair"); XmlNode en = xml_doc.CreateElement("en"); XmlNode de = xml_doc.CreateElement("de"); en.InnerText = p.En; de.InnerText = p.De; pair.AppendChild(en); pair.AppendChild(de); lesson.AppendChild(pair); } root.AppendChild(lesson); } xml_doc.AppendChild(root); xml_doc.Save(xml_path); }
public saveConfig(String fileName) { if (fileName == null || fileName.Equals("")) { path = ".\\" + defaultPath; } else { path = ".\\" + fileName; } try { if (File.Exists(path)) { XmlDoc.Load(path); XmlNode all = XmlDoc.SelectSingleNode("All"); Console.WriteLine(all.ChildNodes.Count); } else { log.writeLog("saveConfig模块:\n配置文件不存在,正在新建文件", log.msgType.warning); XmlElement all = XmlDoc.CreateElement("All"); XmlDoc.AppendChild(all); XmlDoc.Save(path); } } catch { log.writeLog("saveConfig模块:\n未知错误,正在重建文件", log.msgType.warning); Delete(); XmlDoc.DocumentElement.RemoveAllAttributes(); XmlElement all = XmlDoc.CreateElement("All"); try { XmlDoc.AppendChild(all); } catch { } XmlDoc.Save(path); } //catch (XmlException) //{ // log.writeLog("saveConfig模块:\n配置文件损坏,正在重建文件", log.msgType.warning); // XmlElement all = XmlDoc.CreateElement("All"); // XmlDoc.AppendChild(all); // XmlDoc.Save(defaultPath); //} //catch (NullReferenceException) //{ // log.writeLog("saveConfig模块:\n配置文件被篡改导致读取出错,正在重建文件", log.msgType.warning); // XmlDoc.DocumentElement.RemoveAllAttributes(); // XmlElement all= XmlDoc.CreateElement("All"); // XmlDoc.AppendChild(all); // XmlDoc.Save(defaultPath); //} //catch { // log.writeLog("saveConfig模块:\n未知错误,正在重建文件", log.msgType.warning); // XmlElement all = XmlDoc.CreateElement("All"); // XmlDoc.AppendChild(all); // XmlDoc.Save(defaultPath); //} }
public XmlDocument GenerateXML() { XmlDataDocument doc = new XmlDataDocument(); XmlElement SensorNetwork = doc.CreateElement(Parsing.SENSORNETWORK_NODE_NAME); doc.AppendChild(SensorNetwork); XmlElement systemName = doc.CreateElement(Parsing.SYSTEM_NODE_NAME); systemName.InnerText = this.SystemName; SensorNetwork.AppendChild(systemName); XmlElement network = doc.CreateElement(Parsing.NETWORK_NODE_NAME); network.AppendChild(Network.WriteToXml(doc)); SensorNetwork.AppendChild(network); if (LinkList != null && LinkList.Count > 0) { XmlElement linkList = doc.CreateElement(Parsing.LINK_NODE_NAME); foreach (string s in LinkList) { XmlElement link = doc.CreateElement("LinkElement"); link.InnerText = s; linkList.AppendChild(link); } SensorNetwork.AppendChild(linkList); } XmlElement assertion = doc.CreateElement(Parsing.ASSERTION_NODE_NAME); assertion.InnerText = this.Assertion; SensorNetwork.AppendChild(assertion); XmlElement sensors = doc.CreateElement(Parsing.SENSORS_NODE_NAME); foreach (var sensor in Sensors) { XmlElement sensorTag = doc.CreateElement("Sensor"); XmlElement sensorID = doc.CreateElement("ID"); sensorID.InnerText = sensor.Key; sensorTag.AppendChild(sensorID); XmlElement tosID = doc.CreateElement("TOSID"); tosID.InnerText = sensor.Value.TOS_ID; sensorTag.AppendChild(tosID); XmlElement sensorApp = doc.CreateElement("App"); sensorApp.InnerText = sensor.Value.TopConfiguration; sensorTag.AppendChild(sensorApp); XmlElement sensorRange = doc.CreateElement("Range"); sensorRange.InnerText = sensor.Value.SensorRanges; sensorTag.AppendChild(sensorRange); if (!string.IsNullOrEmpty(sensor.Value.PredefinedVars)) { XmlElement sensorPredefVars = doc.CreateElement("Predefined"); sensorPredefVars.InnerText = sensor.Value.PredefinedVars; sensorTag.AppendChild(sensorPredefVars); } sensors.AppendChild(sensorTag); } SensorNetwork.AppendChild(sensors); return(doc); }