对于将TXT文档中数据导入XML中的程序网上不多,但是有很多是先将TXT导入到DataSet中,在用XML进行传输。所以本人就在这里与大家分享一下直接导入的这种方式。
本程序也可以应用于ASP.NET中,那么下面的命名空间及一些地方就得改改了,还有要将程序都放于Page_Load中。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Xml;
namespace Read
{
public partial class Form1 : Form
{
XmlDocument xmldoc;
XmlNode xmlnode;
XmlElement xmlelem;
XmlElement xmlelem2;
double[,] tokens ={ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } };
public Form1()
{
InitializeComponent();
}
//先将TXT文档中数据转存到数组tokens中
private void btn_send_Click(object sender, EventArgs e)
{
string line;