一个很简单问题~!!!!

FrostG 2003-09-30 09:43:49
在ASP.NET当中.我怎么把用户输入的信息写进XML文件里呢~!?我知道有这样一个类.
请问是哪个类...怎么用...谢谢了~!!!
...全文
34 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
qimini 2003-09-30
  • 打赏
  • 举报
回复
昏,點'管理'
FrostG 2003-09-30
  • 打赏
  • 举报
回复
喔...这样啊...谢谢咯~!!!
对了...怎么给分数啊~!?
zhenwang 2003-09-30
  • 打赏
  • 举报
回复
给你一个简洁的步骤:
1、创建一个XMLDocument对象,用于载入存储信息的XML文件;
XmlDocument xdoc=new XmlDocument();
xdoc.Load(Server.MapPath("XML文件名.xml"));

2、创建一个新的主节点,并将它添加到跟节点下:
XmlElement parentnode=xdoc.CreateElement("MainNode");
xdoc.DocumentElement.PrependChild(parentnode);

3、创建所有用于存储信息的子节点:
XmlElement node1=xdoc.CreateElement("node1");
XmlElement node2=xdoc.CreateElement("node2");
......................

4、将上面创建的各个存储信息的节点添加到主节点下但并不包含最终的值:
parentnode.AppendChild(node1);
parentnode.AppendChild(node2);
...........................

5、将要添加的文本信息添加到各个节点中去:
node1.AppendChild("----文本信息---");
node2.AppendChild("----文本信息---");

6、保存存储信息的XML文件
xdoc.Save(Server.MapPath("xml文件名.xml"));

按照上面的方法创建的 xml文件将具有如下格式:
<?xml version="1.0" encoding="gb2312"?>
<mainnode>
<node1>....</node1>
<node2>.....</node2>
</mainnode>
qimini 2003-09-30
  • 打赏
  • 举报
回复
====================A sample From MSDN 2003

Input

data1|data2|data3|data4|data5

and you would like to transform it to :

Output

<data>
<item> data1 </item>
<item> data2 </item>
<item> data3 </item>
<item> data4 </item>
<item> data5 </item>
</data>

A method is created to tokenize the data in the file into individual data tokens. Each call to this function returns one of the data elements. The method takes in a StreamReader.


[C#]
public static String NextToken(StreamReader stream)
{
int temp = stream.Read();
String t1 = "";
while(temp != -1 && temp != (int)'|')
{
t1 += (char)temp;
temp = stream.Read();
}
return t1;
}

The code iterates through until there are no data tokens remaining; inserting each token into an XML document. This is done in the Main function, which takes two command line arguments. The first argument is the file to read from, the second is the file to write to. The comments within the code provide a description of the actions taking place.

[C#]
using System;
using System.IO;
using System.Xml;

namespace TextFiletoXml
{

class TextFiletoXml
{
public static String file;
public static StreamReader stream;
public static XmlTextWriter xwriter;
public static String val;
public static String NextToken(StreamReader stream)
{
int temp = stream.Read();
String t1 = "";
while(temp != -1 && temp != (int)'|')
{
t1 += (char)temp;
temp = stream.Read();
}

return t1;

}

public static void Main(string[] args)
{
file = args[0];

//Create a new stream representing the file we are
//reading from.
stream = new StreamReader(file, true);

//Create a new XmlTextWriter.
xwriter = new XmlTextWriter(args[1],System.Text.Encoding.UTF8);
//Write the beginning of the document including the
//document declaration. Standalone is true.

xwriter.WriteStartDocument(true);

//Write the beginning of the "data" element. This is
//the opening tag to our data

xwriter.WriteStartElement("data","www.alpineskihouse.com");

// Get the first data element from the file.
val = NextToken(stream);

//create a new element with each data token from //the stream.
while(val != "")
{

xwriter.WriteElementString("item","www.alpineskihouse.com", val);
val = NextToken(stream);
}
//End the "data" element.
xwriter.WriteEndElement();

//End the document
xwriter.WriteEndDocument();

//Flush the xml document to the underlying stream and
//close the underlying stream. The data will not be
//written out to the stream until either the Flush()
//method is called or the Close() method is called.
xwriter.Close();
}
}
}
qimini 2003-09-30
  • 打赏
  • 举报
回复
==================== From MSDN 2003

Input

data1|data2|data3|data4|data5

and you would like to transform it to :

Output

<data>
<item> data1 </item>
<item> data2 </item>
<item> data3 </item>
<item> data4 </item>
<item> data5 </item>
</data>

A method is created to tokenize the data in the file into individual data tokens. Each call to this function returns one of the data elements. The method takes in a StreamReader.


[C#]
public static String NextToken(StreamReader stream)
{
int temp = stream.Read();
String t1 = "";
while(temp != -1 && temp != (int)'|')
{
t1 += (char)temp;
temp = stream.Read();
}
return t1;
}

The code iterates through until there are no data tokens remaining; inserting each token into an XML document. This is done in the Main function, which takes two command line arguments. The first argument is the file to read from, the second is the file to write to. The comments within the code provide a description of the actions taking place.

[C#]
using System;
using System.IO;
using System.Xml;

namespace TextFiletoXml
{

class TextFiletoXml
{
public static String file;
public static StreamReader stream;
public static XmlTextWriter xwriter;
public static String val;
public static String NextToken(StreamReader stream)
{
int temp = stream.Read();
String t1 = "";
while(temp != -1 && temp != (int)'|')
{
t1 += (char)temp;
temp = stream.Read();
}

return t1;

}

public static void Main(string[] args)
{
file = args[0];

//Create a new stream representing the file we are
//reading from.
stream = new StreamReader(file, true);

//Create a new XmlTextWriter.
xwriter = new XmlTextWriter(args[1],System.Text.Encoding.UTF8);
//Write the beginning of the document including the
//document declaration. Standalone is true.

xwriter.WriteStartDocument(true);

//Write the beginning of the "data" element. This is
//the opening tag to our data

xwriter.WriteStartElement("data","www.alpineskihouse.com");

// Get the first data element from the file.
val = NextToken(stream);

//create a new element with each data token from //the stream.
while(val != "")
{

xwriter.WriteElementString("item","www.alpineskihouse.com", val);
val = NextToken(stream);
}
//End the "data" element.
xwriter.WriteEndElement();

//End the document
xwriter.WriteEndDocument();

//Flush the xml document to the underlying stream and
//close the underlying stream. The data will not be
//written out to the stream until either the Flush()
//method is called or the Close() method is called.
xwriter.Close();
}
}
}
qimini 2003-09-30
  • 打赏
  • 举报
回复
XmlWriter
想每月25号,信用卡自动还款想每年4月1日自己给当年暗恋女神发一封匿名贺卡想每隔1小时,备份一下自己的爱情片 学习笔记到云盘这些问题总结起来就是:在某一个有规律的时间点干某件事。并且时间的触发的条件可以非常复杂(比如每月最后一个工作日的17:50),复杂到需要一个专门的框架来干这个事。 以上这些是我们日常常见的任务调度需求,企业里面会有大量的任务调度需求,可以说任务调度是一个企业很重要的一部分。传统的定时任务有很多的缺点,1、不支持集群:集群情况下容易造成任务重复问题2、不支持失败重试:失败即结束,不支持重试3、不支持动态调整:修改任务参数时需要修改代码,并且要重启服务4、无报警机制:任务失败后没有提醒功能5、无统一管理:没有办法手动关闭或开启任务针对上面的一些问题和缺点,XXL-JOB可以实现我们的需求。 XXL-JOB是一个开源的,具有丰富的任务管理功能以及高性能,高可用等特点的轻量级分布式任务调度平台,其核心设计目标是开发迅速、学习简单、轻量级、易扩展、开箱即用!!! 课程会带大家构建XXL-JOB调度平台,实战讲解多种类型任务调度配置,会基于大数据推荐系统案例讲解XXL-JOB使用,让大家在实战中掌握XXL-JOB。课程所用的开发环境为:Window10 开发工具:IDEA 本课程用到技术:XXL-JOBKafkaHiveHadoopSparkFlumeMySQLZookeeper等 
内容简介: Redis的的是完全开源免费的,遵守BSD协议,是一个高性能的键值数据库。是当前最热门的的的NoSql数据库之一,也被人们称为数据结构服务器。本课程从Redis基本数据类型开始,了解不同数据类型的用法和底层实现 。进一步学习Redis的一些高级特性与工作原理。了解Redis在分布式环境中的工作方式,和实际项目的使用及问题解决。 为什么学Redis? 原因很简单,快!这个问题在大并发,高负载的网站中必须考虑.redis数据库中的所有数据都存储在内存中。由于内存的读写速度远快于硬盘,因此Redis在性能上对比其他基于硬盘存储的数据库有非常明显的优势。项目中使用Redis,主要是从两个角度去考虑:性能状语从句:并发。当然,Redis的的的还具备可以做分布式锁等其他功能,但是如果只是为了分布式锁这些其他功能,完全还有其他中间件代替,并不是非要使用Redis的的的。因此,这个问题主要从性能和并发两个角度去答。性能:我们在碰到需要执行耗时特别久,且结果不频繁变动的SQL,就特别适合将运行结果放入缓存,这样,后面的请求就去缓存中读取,请求使得能够迅速响应。 并发: 在大并发的情况下,所有的请求直接访问数据库,数据库会出现连接异常。这个时候,就需要使用的的Redis的做一个缓冲操作,让请求先访问到的Redis的的,而不是直接访问数据库。redis优势:1.运行在内存,速度快官方号称支持并发11瓦特读操作,并发8瓦特写操作,可以说是相当彪悍了。2.数据虽在内存,但是提供了持久化的支持,即可以将内存中的数据异步写入到硬盘中,同时不影响继续提供服务3.支持数据结构丰富(string(字符串),list(链表),set(集合),zset(sorted set - 有序集合))和Hash(哈希类型,md5加密出来的那个串)课程大纲: 为了让大家快速系统了解Redis核心知识全貌,我为你总结了「Redis核心框架图」,帮你梳理学习重点,建议收藏!!
       在Java界,Netty无疑是开发网络应用的拿手菜。你不需要太多关注复杂的NIO模型和底层网络的细节,使用其丰富的接口,可以很容易的实现复杂的通讯功能。 本课程准备的十二个实例,按照由简单到复杂的学习路线,让你能够快速学习如何利用Netty来开发网络通信应用。                每个实例简洁、清爽、实用,重点在“用”上,即培训大家如何熟练的使用Netty解决实际问题,抛弃以往边讲应用边分析源码的培训模式所带来的“高不成低不就”情况,在已经能够熟练使用、并且清楚开发流程的基础上再去分析源码就会思路清晰、事半功倍。        本套课程的十二个实例,各自独立,同时又层层递进,每个实例都是针对典型的实际应用场景,学了马上就能应用到实际项目中去。 学习好Netty 总有一个理由给你惊喜!! 一、应用场景        Netty已经众多领域得到大规模应用,这些领域包括:物联网领域、互联网领域、电信领域、大数据领域、游戏行业、企业应用、银行证券金融领域、。。。  二、技术深度        多款开源框架中应用了Netty,如阿里分布式服务框架 Dubbo 的 RPC 框架、淘宝的消息中间件 R0cketMQ、Hadoop 的高性能通信和序列化组件 Avro 的 RPC 框架、开源集群运算框架 Spark、分布式计算框架 Storm、并发应用和分布式应用 Akka、。。。  三、就业前景         很多大厂在招聘高级/资深Java工程师时要求熟练学习、或熟悉Netty,下面只是简要列出,这个名单可以很长。。。

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧