易截截图软件、单文件、免安装、纯绿色、仅160KB

C#写XML的简单例子

这个例子要把bookstore.xml文件增加一条book记录
1 bookstore.xml
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
  <book genre="love" ISBN="1234123">
    <title>who am i </title>
    <author>who</author>
    <price>999</price>
  </book>
</bookstore>
2 bookstore.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
namespace toxml
{
    public class ToXml
    {
        public static void Main(string[] args)
        {
            //实例化一个XmlDocument对象
            XmlDocument xmlDoc = new XmlDocument();
            //实例对象读取要写入的XML文件
            xmlDoc.Load("bookstore.xml");
            //查找<bookstore>
            XmlNode root = xmlDoc.SelectSingleNode("bookstore");
            //创建一个<book>节点
            XmlElement xe1 = xmlDoc.CreateElement("book");
            //设置该节点genre属性
            xe1.SetAttribute("leixing", "music");
            //设置该节点ISBN属性   
            xe1.SetAttribute("ISBN", "56756");
         


相关文档:

c#简单操作注册表

一、首先先添加引用    using Microsoft.Win32;     
//因为操作注册表的两个类RegistryKey和Registry都包含在此引用中;
 
二、编写代码开始操作注册表
1、 #region      限制软件的使用次数
        pri ......

C# 回滚1

c#事务回滚(转)
作者:xue5ya  来源:博客园  发布时间:2009-03-20 16:08  阅读:263 次  原文链接   [收藏]  
Code
public void UpdateContactTableByDataSet(DataSet ds,string strTblName) 

    ......

C#的TCP通信


TCP是连接模型,如下:
服务器连接                     服务器断开
    ↓                   ......

asp.net的XML通用操作类

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Syste ......

Symbian——解析XML文件

ZT:http://www.mobpub.net/archiver/?tid-28.html
Symbian学习笔记(15)——解析XML文件(上)
今天想分享的是如何在Symbian平台上解析XML文件,不需要第三方的东西,Symbian已经为我们提供了这个类CParser。
网上也有这方面的资料,建议参考:
[url]http://wiki.forum.nokia.com/index.php/How_to_parse_XML_fi ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号