您好,登錄后才能下訂單哦!
- XmlDocument xmlDocument = new XmlDocument(); //create xml document
- XmlNode xmlNode = xmlDocument.CreateNode(XmlNodeType.XmlDeclaration, "", ""); //xml document header declaration
- xmlDocument.AppendChild(xmlNode); // add xml document header declarations
- XmlElement xmlElement = xmlDocument.CreateElement("", "TestDataModels", ""); //create xml root node
- XmlElement element = xmlDocument.CreateElement("", "TestDataModels", ""); //create TestDataModels' child node
- for (int i = 1; i < 6; i++)
- {
- XmlElement element = xmlDocument.CreateElement("", "TestDataModels", ""); //create TestDataModels' child node
- //add child node for the TestDataModels's node
- XmlElement elementCode = xmlDocument.CreateElement("Test", "Code", "");
- XmlText xmlTextCode = xmlDocument.CreateTextNode(tm.TCode);
- elementCode.AppendChild(xmlTextCode);
- element.AppendChild(elementCode);
- XmlElement elementName = xmlDocument.CreateElement("Test", "Name", "");
- XmlText xmlTextName = xmlDocument.CreateTextNode(tm.TName);
- elementName.AppendChild(xmlTextName);
- element.AppendChild(elementName);
- //testType start
- XmlElement elementType = xmlDocument.CreateElement("Test", "Type", "");
- XmlElement elementTypeCode = xmlDocument.CreateElement("Type", "TCode", "");
- XmlText xmlTextTypeCode = xmlDocument.CreateTextNode(tt.TtCode);
- elementTypeCode.AppendChild(xmlTextTypeCode);
- elementType.AppendChild(elementTypeCode);
- XmlElement elementTypeName = xmlDocument.CreateElement("Type", "TName", "");
- XmlText xmlTextTypeName = xmlDocument.CreateTextNode(tt.TtName);
- elementTypeName.AppendChild(xmlTextTypeName);
- elementType.AppendChild(elementTypeName);
- element.AppendChild(elementType);
- //testType end
- xmlElement.AppendChild(element); //For xmlElement add child element
- }
- xmlDocument.AppendChild(xmlElement); //For xmlDocument add child node
- xmlDocument.Save(dataFile); //save the xmlDocument
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。