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

c# xml操作

已知有一个XML文件(bookstore.xml)如下:
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
  <book genre="fantasy" ISBN="2-3631-4">
    <title>Oberon's Legacy</title>
    <author>Corets, Eva</author>
    <price>5.95</price>
  </book>
</bookstore>
 
  1、往<bookstore>节点中插入一个<book>节点:
   XmlDocument xmlDoc=new XmlDocument();
   xmlDoc.Load("bookstore.xml");
   XmlNode root=xmlDoc.SelectSingleNode("bookstore");//查找<bookstore>
   XmlElement xe1=xmlDoc.CreateElement("book");//创建一个<book>节点
   xe1.SetAttribute("genre","李赞红");//设置该节点genre属性
   xe1.SetAttribute("ISBN","2-3631-4");//设置该节点ISBN属性
 
   XmlElement xesub1=xmlDoc.CreateElement("title");
   xesub1.InnerText="CS从入门到精通";//设置文本节点
   xe1.AppendChild(xesub1);//添加到<book>节点中
   XmlElement xesub2=xmlDoc.CreateElement("author");
   xesub2.InnerText="候捷";
   xe1.AppendChild(xesub2);
   XmlElement xesub3=xmlDoc.CreateElement("price");
   xesub3.InnerText="58.3";
   xe1.AppendChild(xesub3);
 
   root.AppendChild(xe1);//添加到<bookstore>节点中
   xmlDoc.Save("bookstore.xml");
  //================
  结果为:
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
  <book genre="fantasy" ISBN="2-3631-4">
    <title>Oberon's Legacy</title>
    <author>Corets, Eva</author>
    <price>5.95</price>
  </book>
  <book genre="李赞红" ISBN="2-3631-4">
    <title>CS从入门到精通</title>
    <author>候捷</author>
 &n


相关文档:

XML中含有html标签的问题

看结论请直接看下面
今天写生成xml的php。没有用什么XMLDOMNode之类的来生成,而是直接echo出xml的内容。
xml的内容中有一部分的数据是从db中循环取出的,问题就出在这。我发现全部取出数据时,对于生成的xml,simplexml_load_string返回false,即表明生成的xml是非法的。
debug一下,发现取出数据加以限制 limit 8 一下 ......

c#与最牛vb算法比拼 by Error


 
文章来源: http://www.zoesan.com By Error 302777528转载请注明出处
以上vb用到指针技术查找字符串与c#一般的.indexof()查找相比较,明显看出谁快谁慢。
VB:
Option Explicit
'指针方法操作字符串
'Copy一个字符串到缓存中
Public Declare Function GetTickCount Lib "kernel32" () As Long
Public ......

用C#开发批量ACCESS数据库压缩程序

下面给出了使用C# 开发的一个压缩ACCESS数据库的程序
像FolderBrowserDialog(用于浏览选择文件夹的对话框)、MessageBox(消息处理对话框)、DirectoryInfo(目录信息,可用于创建、检测是否存在等对目录的操作)、FileInfo(文件信息,可用于文件的检测、文件信息的获取、复制等操作)、DataGridView(数据表格控件,用� ......

Sqlite在C#中的应用

在 .NET 里面使用 SQLite, 我这里使用的wrapper是 System.Data.SQLite,它只需要一个dll,接口符合ADO.Net 2.0的定义,性能也不错,NHibernate用的也是它,目前支持ADO.NET 3.5了,支持集成在 VS2005 和 VS2008里面,而且支持wince,是个亮点
因为符合ADO.NET的规范,所以使用方式,基本和 SqlClient, OleDb等原生的一致
us ......

VB.NET/C# and JavaScript communication

Introduction
This article is about passing data between VB.NET/C# WinForms and JavaScript.
Before reading further, let me warn you that this article is not about ASP.NET. Concepts covered in the article are applied to Desktop applications.
Background
I was working on a project which required dat ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号