本文介绍了嗨,大家好。我已经制作了Xml文件用于存储多个记录但我不想编辑任何记录我怎么能做Plz。这是我的Xml代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 此代码仅生成xml文件。 this code only make xml file.private void btnCreatexml_Click(object sender, EventArgs e) { XmlTextWriter xwriter = new XmlTextWriter("Employee.Xml", Encoding.UTF8); xwriter.Formatting = Formatting.Indented; xwriter.WriteStartElement("Employees"); xwriter.WriteStartElement("EmpInformation"); xwriter.WriteStartElement("name"); xwriter.WriteString(textBox1.Text); xwriter.WriteEndElement(); xwriter.WriteStartElement("age"); xwriter.WriteValue(textBox2.Text); xwriter.WriteEndElement(); xwriter.WriteStartElement("email"); xwriter.WriteString(textBox3.Text); xwriter.WriteEndElement(); xwriter.WriteEndElement(); xwriter.WriteEndElement(); xwriter.Close(); } 这个代码用于商店multy recodes.but我想编辑任何来自xml文件的重新编码我有什么plz帮助我这个主题thnx b $ b and this code is for store multy recodes.but i want to edit any recode from xml file what i have plz help me on this topic thnxprivate void btnAddrecord_Click(object sender, EventArgs e) { XmlDataDocument doc = new XmlDataDocument(); doc.Load("Employee.Xml"); XmlNode EmpInformation = doc.CreateElement("EmpInformation"); XmlNode name = doc.CreateElement("name"); name.InnerText = textBox1.Text.Trim(); EmpInformation.AppendChild(name); XmlNode age = doc.CreateElement("age"); age.InnerText = textBox2.Text.Trim(); EmpInformation.AppendChild(age); XmlNode email = doc.CreateElement("email"); email.InnerText = textBox3.Text.Trim(); EmpInformation.AppendChild(email); doc.DocumentElement.AppendChild(EmpInformation); doc.Save("Employee.Xml"); } 推荐答案 这看起来就像你正在尝试创建一个存储数据库的地方,就像数据一样大,要做的大任务。为什么不使用现成的东西,例如 RaptorDB - 文档存储 [ ^ ]。 那里有很多选择。甚至免费的SQL数据库,如SQL Server Express版。一切都取决于你所追求的。 :)This looks like you're trying to create a place to store database like data which is a big, big task to do. Why not using something ready made, for example RaptorDB - the Document Store[^]. There are a lot of choices out there. Even free SQL Databases such as SQL Server Express edition. All depending what you're after. :) 您可以填充DataSet来读取和写入XML文件: https://msdn.microsoft.com/en-us/library/ekw4dh3f.aspx [ ^ ] https://www.daniweb.com/software-development/csharp/threads/343670/use- of-xml-file-in-c-instead-database-based [ ^ ] 使用此类DataSet,您可以将数据绑定到任何数据 - 控制,像Grid一样,并根据需要进行编辑...... You can fill a DataSet to read and write XML file:https://msdn.microsoft.com/en-us/library/ekw4dh3f.aspx[^]https://www.daniweb.com/software-development/csharp/threads/343670/use-of-xml-file-in-c-instead-of-database[^]Using such DataSet you can bind your data to any data-control, like Grid and edit it as you want... 这篇关于嗨,大家好。我已经制作了Xml文件用于存储多个记录但我不想编辑任何记录我怎么能做Plz。这是我的Xml代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-25 09:04