易截截图软件、单文件、免安装、纯绿色、仅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>
<price>58.3</price>
</book>
</bookstore>

2、修改节点:将genre属性值为“李赞红“的节点的genre值改为“update李赞红”,将该节点的子节点&l


相关文档:

C#.NET的Web控件是否支持CSS

Web控件是否支持样式表(CSS)呢?
支持,所有的Web控件都从基类System.Web.UI.WebControls.WebControl中继承了一个叫做CssClass的属性。
示例源代码:
<html>
<head>
<style>
.Input { font: 10pt verdana; color: red; }
</style>
</head>
<body>
<form runat=& ......

ArrayList从xml读取数据

ArrayAdapter adapter =
ArrayAdapter.createfromResource(
this,
R.array.catalog,
android.R.layout.simple_list_item_1);

this.setListAdapter(adapter); 
xml文件
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name= ......

一个C# xml 序列化错误

一个C# xml 序列化错误
 
事发现场:
xml序列化的数据中存储的节点数据是
   <Module>536870912</Module>  (xml文件中)
对应的类属性是
    public short Module { get; set; }  (C#类中)
 
序列化的代码:
public static FMDSTimeSeriesDefinitio ......

JDom输出UTF 8的XML完美解决

转贴地址:http://java.chinaitlab.com/advance/755393.html
现象描述:JDom输出Xml文件,当使用字符编码GBK时正常,而输出UTF-8时乱码。
    完美的解决方法从辟谣开始:
    1)JDOM是否生成UTF-8的文件与Format是否设置无关,只有输出其他字符编码才需要设置,见下面的注释。
 & ......

Javascript函数中调用C#方法

一、后台(.cs文件)方法:
       public string GetString(string name)
        {
            return ("Hello " + name);
        }
&n ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号