XmlNode root = xmlDoc.SelectSingleNode("news");
参考
http://www.cnblogs.com/ziyan22/archive/2007/08/23/866456.html
参考
http://www.cnblogs.com/ziyan22/archive/2007/08/23/866456.html
解决方案 »
- UDP 通信, 线程接受 遇到问题啦
- C#中利用双缓冲绘图问题
- 传真的收发程序实现.
- 我在Vs中写String a = new String("ab")会报错,请问为什么?
- 请教如何读取文本文件进行筛选后导入到datatable中
- 学习堆栈遇到的一个问题 100分献上
- winfrom(C#)中将设置好的字体颜色能一起保存至数据库,然后读出来也已设置好吗?
- 用水晶报表或其他第三方控件打印大文本时,如果文本超过1页,怎么办?
- 问C# Windows程序的优化!
- 矢量变换及合成的难题
- 哥们,谁有做过CODE128A条形码的请通知本姑娘一下,想向你老人家讨教一下!
- 在C#验证码里有随机大小写、奇偶数怎么写。
string url = Server.MapPath("/sitemap/Sitemaps.xml");
XmlDocument xmlDoc = new XmlDocument();
string news_title = "12311";
string news_time = "2008-12-05";
XmlNode root = xmlDoc.CreateElement("histNews");
XmlElement news = xmlDoc.CreateElement("news");
XmlElement title = xmlDoc.CreateElement("title");
title.InnerText = news_title;
news.AppendChild(title);
XmlElement time = xmlDoc.CreateElement("time");
time.InnerText = news_time;
news.AppendChild(time);
root.AppendChild(news);
xmlDoc.AppendChild(root);
xmlDoc.Save(url);
XmlDocument xmlDoc = new XmlDocument();
//xmlDoc.Load(url);
string news_title = "12311";
string news_time = "2008-12-05";
XmlNode root = xmlDoc.CreateElement("histNews");
XmlElement news = xmlDoc.CreateElement("news");
XmlElement title = xmlDoc.CreateElement("title");
title.InnerText = news_title;
news.AppendChild(title);
XmlElement time = xmlDoc.CreateElement("time");
time.InnerText = news_time;
news.AppendChild(time);
root.AppendChild(news);
xmlDoc.AppendChild(root);
xmlDoc.Save(url); 注意:搂主还需确信sitemap文件夹是存在的,否则得先创建好
<news>
<title>什么什么什么 </title>
<time>2008-12-11 </time>
</news>
<histNews>
结尾的时候要关闭</histNews>
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(url);
string news_title = "12311";
string news_time = "2008-12-05";
XmlNode root = xmlDoc.DocumentElement;
XmlElement news = xmlDoc.CreateElement("news", "http://www.163.com/rss/0.9");
XmlElement title = xmlDoc.CreateElement("title", "http://www.163.com/rss/0.9");
title.InnerText = news_title;
news.AppendChild(title);
XmlElement time = xmlDoc.CreateElement("time", "http://www.163.com/rss/0.9");
time.InnerText = news_time;
news.AppendChild(time);
root.AppendChild(news);
xmlDoc.Save(url);
搂主是要创建这个XML,所以不需要这个XML文件事先已经存在的,直接使用3楼代码就可以啦