C#操作xml
引用命名空间:using System.Xml
1.检查所要操作的xml文件是否存在:
System.IO.File.Exists(文件路径及名称);
2.得到xml文件:
(1)在asp.net中可以这样得到:
XmlDocument xmlDoc = new XmlDocument();
//导入xml文档
xmlDoc.Load( Server.MapPath("xmlTesting.xml"));
//导入字符串
//xmlDoc.LoadXml("<bookStore> <book id="01" price="3.5元"> 读者</book></bookStore>");
注:Server.MapPath("xmlTesting.xml")此时的xmlTesting.xml文件必须是在当前的解决方案里;同样可以写成完整的物理路径xmlDoc.Load (@"E:"软件学习"测试"myNoteWeb"xmlTesting.xml")
(2)在windForm中 直接用物理路径得到所要操作的xml文件具体实现方法同上
3.创建xml文件:
XmlDocument xmlDoc = new XmlDocument(); //创建xml文档(实例化一个xml)
XmlNode root = xmlDoc.CreateElement("bookStore");//创建根节点
//创建第1个子结点:
XmlNode bookNode = xmlDoc.CreateElement("book");
bookNode.InnerText = "读者";
//为此节点添加属性
法1:
bookPublishNode.SetAttribute("id", "01")
root.AppendChild(bookNode);
法2:
XmlAttribute xmlattribute = tempXmlDoc.CreateAttribute("price");
xmlattribute.Value = "3.5元";
tempRoot .Attributes .Append (xmlattribute )
//创建第2个根节点的子结点:
XmlNode tempBookNode = xmlDoc.CreateElement("tempbook ");
tempBookNode.InnerText ="文摘";
root.AppendChild(tempBookNode);
相关文档:
//Socket基本编程
//服务端:
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
Thread mythread ;
Socket socket;
// 清理所有正在使用的资源。
protected override void Dispose( bool disposing )
{
try
{
socket.Close();//释放资源
......
c#改变系统鼠标
---------------------------------------------------------------------------------------------------
using System.Runtime.InteropServices;
[DllImport("User32.DLL")]
public static extern bool SetSystemCursor(IntPtr hcur, uint id);
public const uint OCR_NORMAL = 32512;
publ ......
RSA
实际应用中是:接收方产生公钥和私钥,发送方用其公钥加密,再把加密后的内容发送给接收方。
CspParameters
的名称空间是:
System.Security.Cryptography
CspParameters cpSend = new CspParameters(); //Csp = Cryptography Service Provider
CspParameters cpReceive = new CspParameters();
cpSend.KeyCon ......
问:C# 加密后为何有两种结果的字符串?
比如 cftea 的 MD5 加密后:
有的人的结果是:c2e1861ca90e67ce1f9a62f9c27d8bdc
有的人的结果是:wuGGHKkOZ84fmmL5wn2L3A
答:这是对字节的两种不同表示结果。
第一种是用十六进制表示的(FormsAuthentication.HashPasswordForStoringInConfigFile 就是这种,只是是大写的), ......
C#连接Oracle数据库字符串
http://developer.51cto.com
2009-08-20 17:55 佚名 百度空间 我要评论(
0
)
C#连接Oracle数据库以及C#连接Oracle数据库字符串等内容将在本文中展现,希望本文能对大家了解C#连接数据库有所帮助。
C#连接Oracle数据库字符串(查询数据)
using
Syst ......