从5个文本框中将数据存储在xml中 [英] store data in xml from 5 text boxes

查看:81
本文介绍了从5个文本框中将数据存储在xml中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将5个文本框中的数据存储在xml中,这些文本框位于窗口应用程序的窗口上.
请告诉我如何完成:doh:

I Want to store data in xml from 5 text boxes which is placed on a window from of window application.
please tell me how it sud be done :doh:

推荐答案

使用此代码将xml插入创建的XML数据中. />
use this code to insert into xml data created....
//Create xml document
XmlDocument XMLDom = new XmlDocument();
XMLDom.Load(@"write your path for xml file");
//Now enter your main xml node	
XmlNode newXMLNode = XMLDom.SelectSingleNode("here is your main nodes name");
XmlNode childNode = XMLDom.CreateNode(XmlNodeType.Element,"Node to enter the data","");
XmlAttribute newAttribute = XMLDom.CreateAttribute("Enter Node Name","Data to be inserted","");
childNode.Attributes.Append(newAttribute);
newXMLNode.AppendChild(childNode);


好吧,因为它是XML,所以您可以任意选择.如果愿意,可以使用字符串构建器来构建XML.您是否只想存储这五个值,还是要存储这五个值的多个实例?您可以使用DOM附加到现有文档,但是可以使用 XmlTextWriter [ ^ ]创建一个新的XML文档.
Well, as it''s XML, any way you like. You can use a string builder to build XML if you like. Do you wnat to just store those five values, or do you want to store multiple instances of those five values. You''d use the DOM to append to an existing document, but I''d use an XmlTextWriter[^] to create a new XML document.


这篇关于从5个文本框中将数据存储在xml中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆