用C#创建XML[简单代码]
XmlDocument doc = new XmlDocument();
XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "GB2312", null);
doc.AppendChild(dec);
//创建一个根节点(一级)
XmlElement root = doc.CreateElement("First");
doc.AppendChild(root);
//创建节点(二级)
XmlNode node = doc.CreateElement("Seconde");
//创建节点(三级)
XmlElement element1 = doc.CreateElement("Third1");
element1.SetAttribute("Name", "Sam");
element1.SetAttribute("ID", "665");
element1.InnerText = "Sam Comment";
node.AppendChild(element1);
XmlElement element2 = doc.CreateElement("Third2");
element2.SetAttribute("Name", "Round");
element2.SetAttribute("ID", "678");
element2.InnerText = "Round Comment";
node.AppendChild(element2);
root.AppendChild(node);
doc.Save(@"E:\bb.xml");
Console.Write(doc.OuterXml);
相关文档:
PKM2这个个人知识管理软件相信很多人用过,可以把数据导出为chm电子书,但是不知道为什么倒出来的chm不能按照标题排序,所以我就导出为xml格式,弄个xsl来显示它.
<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output me ......
<?xml version="1.0" encoding="utf-8"?>
<userdata createuser="false">
<dataconnection>
<server>xml test</server>
<uid>sa</uid>
<pwd>sa</pwd>
</dataconnection> ......
已知有一个XML文件(bookstore.xml)如下:
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book genre="fantasy" ISBN="2-3631-4">
&n ......
创建一个Winform用户控件 UserControl1
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Reflection;
namespace MyActiveT ......
转自江边孤鸟: http://blog.csdn.net/jbgh608/archive/2007/08/31/1767414.aspx
W3school 的xsl教程: http://www.w3school.com.cn/xsl/index.asp
产品几年前使用ASP,后来升级到.Net 1.1,再升级到2.0,一直都有用XSLT转换XML生成网页的方式,稍微整理下。
XML file:
<?xml version="1.0"& ......