C#中用XmlDocument对象获取XML文件中的节点值
xml文件:
<?xml version="1.0" encoding="utf-8" ?>
<bookstore>
<book>
<title lang="eng">Harry Potter</title>
<price>29.99</price>
</book>
<book>
<title lang="eng">Learning XML</title>
<price>39.98</price>
</book>
<bookstore>
<title lang="eng">Learning C#</title>
<price>55.23</price>
</bookstore>
<item name="1">第一个item</item>
<item name="2">
<item name="1">这个结点(1)</item>
<item name="2">这个结点(2)</item>
<book>
<title lang="cn">Learning C</title>
<price>60.95</price>
</book>
</item>
</bookstore>
XmlDocument xdoc = new XmlDocument();
xdoc.Load(Server.MapPath("books.xml"));
XmlNodeList xnl = xdoc.SelectNodes("/bookstore/book");
string nodeTempStr = "";
foreach (XmlNode node in xnl)
{
nodeTempStr = node.InnerText;
node
相关文档:
刚开始很不习惯c#的风格,哎,先入为主啊,delphi习惯了,{}代替begin/end太扎眼。
属性方法的宣告和代码在一起,没有像delphi分interface/implementation,感觉太乱,都不知道一个class到底有几个方法。
每个属性和方法前面都要单独写private/protected/public,老天,c#是delphi之父设计的揶,怎么不学delphi写一个就行 ......
C#组件开发人员
什么时候使用override?什么时候使用new? 什么叫shadowing?
重写父类的方法的时候用override以实现多态,当你想屏蔽父类成员的时候使用new,shadowing基本就是new与override区别等一些方面的问题,个人认为弄清override与new就没有必要特意考虑shadowing。
解释virtual、sealed、override和abstract的 ......
以前在博客上发过,经人提醒DataSet已自带读写XML的功能,于是便删了,
不过在实践中感觉封装一层后,使用起来还是蛮方便的。故再次重发。
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.IO;
using System.Xml;
namespace XmlDesign
{
class XmlDatasetC ......
///通过传入的特定XML字符串,通过 ReadXml函数读取到DataSet中。
protected static DataSet GetDataSetByXml(string xmlData)
{
try
{
&nbs ......
一、建立网页
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<script language="javascript" type="text/javascript">
<!-- 提供给C#程序调用的方法 -->
function messageBox(message)
{
alert(message);
}
</script>
</head>
& ......