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);
相关文档:
熟悉ruby on rails的开发员都知道,在ruby中,有一个很重要的特性,就是能够实现元编程,特别是在用于开发Web应用的rails框架中,用的特别多。在rails中,要创建一个动态方法并与数据库表字段相关联,主要的的步骤大概有这些:
1、首先配置好数据库的连接。
2、创建一个ActiveRecord模型,这个模型与数据库的表名称有一定 ......
using System.Windows.Forms;
using SAPFunctionsOCX;
using SAPLogonCtrl;
using SAPTableFactoryCtrl;
namespace SAPFunction
{
public partial class Form1 : Form
{
public Form1()
  ......
最近着实忙了一阵子,学习了好多东东都没时间整理,呵呵,总算是要放假了,可以好好归纳归纳了。
设计模式的学习是一个任重而道远的过程了,^_^,要好好总结,总结的目的是让自己好好记住,记住的目的是便于理解,而理解的最终目的是应用,O(∩_∩)O~ 而设计模式也往往是应用的一种重构,循环往复,生生不息啊... .. ......
TripleDES
属对称加密,对称加密在加密和解密时都使用相同的密钥,速度快。
TripleDESCryptoServiceProvider 的名称空间是:
System.Security.Cryptography
byte[] plaintextBuffer = System.Text.Encoding.UTF8.GetBytes("明文");
//加密
TripleDESCryptoServiceProvider tripleDES = new TripleDESCrypt ......