2006年4月

昨天把我的笔记本重新安装了一下,用的是番茄花园的ISO自动安装的,安装完成后,注册信息是番茄花园,就想改成自己的名字,于是,从网上搜索到了一个工具,OEMDIY,挺不错的,你可以修改你的注册信息,而且也可以添加OEM信息,比如我的本子是hp的,就可以加上HP的图标,挺方便的一个东西。

需要下载的朋友,请到我的网络硬盘下载。谢谢。
访问密码:0000

这是微软MSDN提供的16节课的C#视频教程,非常适合入门学习。通过创建一个具体的解决方案,了解C#,学习C#,非常好。

大小就是180多M,我已经放在MOFILE了,大家可以下载学习看看。

地址如下:

http://www1.51ok.com/down.do?17F2F2480F6B8741793E40506F89C54E

这次不限制时间了,大家可以尽情的下载了。呵呵。

请查阅该文章:http://www.arvan.net.ru/article.asp?id=273

An axis defines a node-set relative to the current node.
轴定义了相对于当前节的节集

The XML Example Document

XML举例文档

We will use the following XML document in the examples below.
我么将使用该XML文档进行下面的举例说明


Harry Potter
29.99


Learning XML
39.95


XPath Axes

XPath轴

轴名结果
ancestorSelects all ancestors (parent, grandparent, etc.) of the current node[选择了当前节的所有祖(父,祖父,等等)]
ancestor-or-selfSelects all ancestors (parent, grandparent, etc.) of the current node and the current node itself[选择当前节的所有祖并且还有当前节自己]
attributeSelects all attributes of the current node[选择所有当前节的属性]
childSelects all children of the current node[选择所有当前节的子]
descendantSelects all descendants (children, grandchildren, etc.) of the current node[选择所有当前节的孙(子,孙子,等等)]
descendant-or-selfSelects all descendants (children, grandchildren, etc.) of the current node and the current node itself[选择当前节的所有孙以及它本身]
followingSelects everything in the document after the closing tag of the current node[选择所有在关闭当前节标签后的所有内容]
following-siblingSelects all siblings after the current node[选择所有当前节后的兄]
namespaceSelects all namespace nodes of the current node[选择所有当前节的命名空间]
parentSelects the parent of the current node[选择当前节的父]
precedingSelects everything in the document that is before the start tag of the current node[选择当前节之前的所有内容]
preceding-siblingSelects all siblings before the current node[选择所有当前节之前的兄]
selfSelects the current node[选择当前节]
- - - - - -

Location Path Expression

路径表达试定位

A location path can be absolute or relative.
定位路径可以是绝对的也可以是相对的

An absolute location path starts with a slash ( / ) and a relative location path does not. In both cases the location path consists of one or more steps, each separated by a slash:
绝对定位的路径由(/)开始,而相对定位就不这样。定位的路径由一个或多个步骤所组成,每部分由(/)相分隔:

An absolute location path:

/step/step/…

A relative location path:

step/step/…

Each step is evaluated against the nodes in the current node-set.
在当前的节集中每步的赋值是逆向的

A step consists of:

  • an axis (defines the tree-relationship between the selected nodes and the current node)
  • a node-test (identifies a node within an axis)[在轴中鉴定节]
  • zero or more predicates (to further refine the selected node-set)[0个或多个谓语可以来更好的选择节]

The syntax for a location step is:
定位的语法

axisname::nodetest[predicate]

Examples

实例

Example结果
child::bookSelects all book nodes that are children of the current node[选择当前节点下所有为book的子节点]
attribute::langSelects the lang attribute of the current node[选择当前节点下所有属性为lang的内容]
child::Selects all children of the current node[选择当前节下所有的子节]
attribute::Selects all attributes of the current node[选择当前节所有的属性]
child::text()Selects all text child nodes of the current node[选择当前节点所有子节点的文字]
child::node()Selects all child nodes of the current node[选择所有当前节点的子节点]
descendant::bookSelects all book descendants of the current node[选择当前节点所有为book的孙节点]
ancestor::bookSelects all book ancestors of the current node[选择所有当前祖节点为book的节点]
ancestor-or-self::bookSelects all book ancestors of the current node – and the current as well if it is a book node[当前节点和其祖节点为book的节点]
child::*/child::priceSelects all price grandchildren of the current node[当前节点所有含price的孙子节点]
An XPath expression returns either anode-set, a string, a Boolean, or a number.


XPath Operators

Below is a list of the operators that can be used in XPath expressions:

OperatorDescriptionExampleReturn value|Computes two node-sets//book | //cdReturns a node-set with all book and cd elements+Addition6 + 410–Subtraction6 – 42*Multiplication6 * 4

24divDivision8 div 42=Equalprice=9.80true if price is 9.80
false if price is 9.90!=Not equalprice!=9.80true if price is 9.90
false if price is 9.80<Less thanprice<9.80true if price is 9.00
false if price is 9.80<=Less than or equal toprice<=9.80true if price is 9.00
false if price is 9.90>Greater thanprice>9.80true if price is 9.90
false if price is 9.80>=Greater than or equal toprice>=9.80true if price is 9.90
false if price is 9.70ororprice=9.80 or price=9.70true if price is 9.80
false if price is 9.50andandprice>9.00 and price<9.90true if price is 9.80
false if price is 8.50modModulus (division remainder)5 mod 21Let's try to learn some basic XPath syntax by looking at some examples.
让我们来尝试通过观察一些实例来学习基础的XPath语法


The XML Example Document

We will use the following XML document in the examples below.
我们将使用下面这个XML文档来进行实例

"books.xml":


Everyday Italian
Giada De Laurentiis
2005
30.00


Harry Potter
J K. Rowling
2005
29.99


XQuery Kick Start
James McGovern
Per Bothner
Kurt Cagle
James Linn
Vaidyanathan Nagarajan
2003
49.99


Learning XML
Erik T. Ray
2003
39.95

View the "books.xml" file in your browser.


Selecting Nodes

选择节点

We will use the Microsoft XMLDOM object to load the XML document and the selectNodes() function to select nodes from the XML document:
我们使用了XMLDOM对象来加载XML文档并用selectNode()函数来进行XML文档上节点的选择:

set xmlDoc=CreateObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load("books.xml")

xmlDoc.selectNodes(path expression)


Select all book Nodes

选择所有book节点

The following example selects all the book nodes under the bookstore element:
下面这个实例就会选择所有bookstore元素以下的book节点:

xmlDoc.selectNodes("/bookstore/book")

如果你有IE5以上的版本你可以自己来做一下.


Select the First book Node

选择第一个book节点

The following example selects only the first book node under the bookstore element:

xmlDoc.selectNodes("/bookstore/book[0]")

If you have IE 5 or higher you can try it yourself.

Note: IE 5 and 6 has implemented that [0] should be the first node, but according to the W3C standard it should have been [1]!!


Select the prices

选择prices

The following example selects the text from all the price nodes:

xmlDoc.selectNodes("/bookstore/book/price/text()")

If you have IE 5 or higher you can try it yourself.


Selecting price Nodes with Price>35

选择price大于35的price节点

The following example selects all the price nodes with a price higher than 35:

xmlDoc.selectNodes("/bookstore/book
[price>35]/price")

If you have IE 5 or higher you can try it yourself.


Selecting title Nodes with Price>35

选择Price大于35的title节点

The following example selects all the title nodes with a price higher than 35:

xmlDoc.selectNodes("/bookstore/book[price>35]/title")

If you have IE 5 or higher you can try it yourself.

XPath uses path expressions to select nodes or node-sets in an XML document. The node is selected by following a path or steps.
XPath使用路径表达式来选择XML文档的节或是节集。顺着路径或步骤来选择节。

XPath uses path expressions to select nodes or node-sets in an XML document. The node is selected by following a path or steps.
XPath使用路径表达式来选择XML文档的节或是节集。顺着路径或步骤来选择节。

- - - - - -

## The XML Example Document
XML实例文档

We will use the following XML document in the examples below.
举例中我们将使用下面的XML文档

>

>

> Harry Potter 29.99 > Learning XML 39.95 >

- - - - - -

## Selecting Nodes
选择节

XPath uses path expressions to select nodes in an XML document. The node is selected by following a path or steps. The most useful path expressions are listed below:
一些非常有用的路径表达式:

**表达式****描述**
*nodename*Selects all child nodes of the node[选择所有目前节的子节]
/Selects from the root node[从根节进行选择]
//Selects nodes in the document from the current node that match the selection no matter where they are [选择文档中相吻合的节而不管其在文档的何处]
.Selects the current node[选择当前节]
..Selects the parent of the current node[当前节的父节]
@Selects attributes[选择属性]

### Examples
实例

In the table below we have listed some path expressions and the result of the expressions:
下面我们所列举的表格有路径表达式以及其结果:

**路径表达式****结果**
bookstoreSelects all the child nodes of the bookstore element[选择所有bookstore元素的子节]
/bookstoreSelects the root element bookstore **Note:** If the path starts with a slash ( / ) it always represents an absolute path to an element!

[选择了bookstore的根元素。注意:如果路径的开始为(/)那此路径一定是到该元素的绝对路径]
bookstore/bookSelects all book elements that are children of bookstore[选择了所有在bookstore的子元素book元素所包含的所有元素(其实就为bookstore里book元素所包含的元素)]
//bookSelects all book elements no matter where they are in the document[选择所有为book元素的内容而不管book元素处于何处(有不同的父也没关系)]
bookstore//bookSelects all book elements that are descendant of the bookstore element, no matter where they are under the bookstore element[在bookstore元素内所有含有book元素的元素内容(只要book元素的祖元素为bookstore元素那都符合条件)]
//@langSelects all attributes that are named lang[选择所有属性名为lang的属性]

- - - - - -

## Predicates
谓语

Predicates are used to find a specific node or a node that contains a specific value.
谓语用来指定明确的节所含有的特殊的值

Predicates are always embedded in square brackets.
谓语被嵌入在中括号

### Examples
举例

In the table below we have listed some path expressions with predicates and the result of the expressions:
下面的表格列举了一些使用了谓语的路径表达式以及其产生的结果:

**路径表达式****结果**
/bookstore/book[1]Selects the first book element that is the child of the bookstore element[选择了bookstore里的第一个book元素]
/bookstore/book[last()]Selects the last book element that is the child of the bookstore element[选择bookstore里最后一个book元素]
/bookstore/book[last()-1]Selects the last but one book element that is the child of the bookstore element[bookstore中倒数第二个book元素]
/bookstore/book[position()<3]Selects the first two book elements that are children of the bookstore element[在bookstore中前两个book元素]
//title[@lang]Selects all the title elements that have an attribute named lang[选择所有含有lang属性的title元素]
//title[@lang='eng']Selects all the title elements that have an attribute named lang with a value of 'eng'[选择所有含有lang属性并且值为eng的title元素]
/bookstore/book[price>35.00]Selects all the book elements of the bookstore element that have a price element with a value greater than 35.00[选择所有bookstore中book元素里price元素内容大于35.00的book元素]
/bookstore/book[price>35.00]/titleSelects all the title elements of the book elements of the bookstore element that have a price element with a value gr
eater than 35.00[选择bookstore中book的子元素title,并且其兄弟元素price的内容得大于35.00]

- - - - - -

## Selecting Unknown Nodes
选择未知的节

XPath wildcards can be used to select unknown XML elements.
XPath的通配符可以用来选择未知的XML元素

**通配符****描述**
*Matches any element node[相吻合的所有元素节]
@*Matches any attribute node[相吻合的所有属性节]
node()Matches any node of any kind[吻合任何类型的节]

### Examples实例

In the table below we have listed some path expressions and the result of the expressions:
下面的表格我们将列举一些路径表达式以及它们的结果

**路径表达式****结果**
/bookstore/*Selects all the child nodes of the bookstore element[选择所有bookstore的子节]
//*Selects all elements in the document[选择所有文档中的元素]
//title[@*]Selects all title elements which have any attribute[选择元素为title并且其含有属性]

- - - - - -

## Selecting Several Paths
选择数个路径

By using the | operator in an XPath expression you can select several paths.
通过在XPath中使用 | 你可以选择数个路径

### Examples
实例

In the table below we have listed some path expressions and the result of the expressions:
下面的表格我们会列举一些路径表达式以及其结果:

**路径表达****结果**
//book/title | //book/priceSelects all the title AND price elements of all book elements[选择所有book里title和price元素]
//title | //priceSelects all the title AND price elements in the document[选择所有title和price元素]
/bookstore/book/title | //priceSelects all the title elements of the book element of the bookstore element AND all the price elements in the document[选择所有book里的title元素和所有price元素]

In XPath, there are seven kinds of nodes: element, attribute, text, namespace, processing-instruction, comment, and document (root) nodes.
在XPath中有七种nodes(节):元素,属性,文字,命名空间,处理说明,注释,和文档(根)节。


XPath Terminology

XPath术语

Nodes/节

In XPath, there are seven kinds of nodes: element, attribute, text, namespace, processing-instruction, comment, and document (root) nodes. XML documents are treated as trees of nodes. The root of the tree is called the document node (or root node).
XML文档被视为数状的节。树的根部被称为文档的节(或根节)。

Look at the following XML document:
观察下面的XML文档:

<?xml version="1.0" encoding="ISO-8859-1"?>  
<bookstore>  
<book>  
<title lang="en">Harry Potter</title>  
<author>J K. Rowling</author>  
<year>2005</year>  
<price>29.99</price>  
</book>  
</bookstore>  

Example of nodes in the XML document above:
上面举例的XML文档的节有:

<bookstore> (document node)

<author>J K. Rowling</author> (element node)

lang="en" (attribute node)  

Atomic values

原子值

Atomic values are nodes with no children or parent.
原子值是那些没有子或父的节(无上下关系)。

Example of atomic values:
举例中的原子值:

J K. Rowling  
"en"

Items

项目

Items are atomic values or nodes.
项目是原子值或节。


Relationship of Nodes

节之间的关系

Parent/父

Each element and attribute has one parent.
每个元素和属性有一父亲。

In the following example; the book element is the parent of the title, author, year, and price:
下面的举例中:book元素是title,author,year和price的父亲

<book>  
<title>Harry Potter</title>  
<author>J K. Rowling</author>  
<year>2005</year>  
<price>29.99</price>  
</book>  

Children/子

Element nodes may have zero, one or more children.
元素节可能有0个或多个子

In the following example; the title, author, year, and price elements are all children of the book element:
下面的举例中:title,author,year和price元素都是book元素的子元素

<book>  
<title>Harry Potter</title>  
<author>J K. Rowling</author>  
<year>2005</year>  
<price>29.99</price>  
</book>  

Siblings/兄

Nodes that have the same parent.
指那些有相同父的

In the following example; the title, author, year, and price elements are all siblings:
下面的举例中title, author, year, 和 price元素都为兄弟

<book>  
<title>Harry Potter</title>  
<author>J K. Rowling</author>  
<year>2005</year>  
<price>29.99</price>  
</book>  

Ancestors/祖

A node's parent, parent's parent, etc.
节的父,父的父….都为祖

In the following example; the ancestors of the title element are the book element and the bookstore element:
下面的举例中:book元素和bookstore元素都为title元素的祖元素

<bookstore>  
<book>  
<title>Harry Potter</title>  
<author>J K. Rowling</author>  
<year>2005</year>  
<price>29.99</price>  
</book>  
</bookstore>  

Descendants/孙

A node's children, children's children, etc.
节的子,子的子…都为孙

In the following example; descendants of the bookstore element are the book, title, author, year, and price elements:
下面的举例中:bookstore元素的孙有book,title,author,year以及price元素

<bookstore>  
<book>  
<title>Harry Potter</title>  
<author>J K. Rowling</author>  
<year>2005</year>  
<price>29.99</price>  
</book>  
</bookstore>  

XPath is a language for finding information in an XML document. XPath is used to navigate through elements and attributes in an XML document.
Xpath是一种能够在XML文档中寻找信息的语言。它通过XML文档中的元素和属性来进行导航。

——————————————————————————–

What You Should Already Know
你应具备的知识
Before you continue you should have a basic understanding of the following:
在你继续前你应该具备以下知识的基础:

HTML / XHTML
XML / XML Namespaces[命名空间]

——————————————————————————–

What is XPath?
什么是XPath?
XPath is a syntax for defining parts of an XML document
XPath 是针对XML文档部分内容定义的语法
XPath uses path expressions to navigate in XML documents
XPath 使用路径表达式在XML文档中导航
XPath contains a library of standard functions
XPath 包含了一系列标准函数
XPath is a major element in XSLT
XPath 在XSLT当中是一个主要的元素
XPath is a W3C Standard
XPath是W3C标准

——————————————————————————–

XPath Path Expressions
XPath 路径表达式
XPath uses path expressions to select nodes or node-sets in an XML document. These path expressions look very much like the expressions you see when you work with a traditional computer file system.
XPath 使用路径表达式来选择XML文档中的nodes(节)或是node-set(节集)。这些路径表达式看上去与你平时所见的传统计算机文件系统路径非常地相似。

——————————————————————————–

XPath Standard Functions
XPath 标准函数
XPath includes over 100 built-in functions. There are functions for string values, numeric values, date and time comparison, node and QName manipulation, sequence manipulation, Boolean values, and more.
XPath包含了数量超过100的内置函数。这些函数针对字符串值,数字值,日期和时间比较,节操作,顺序操作,布尔值,等等。

——————————————————————————–

XPath is Used in XSLT
XPath被用在XSLT
XPath is a major element in the XSLT standard. Without XPath knowledge you will not be able to create XSLT documents.
在XSLT标准中XPath是主要的元素。没有XPath知识你将很难建立XSLT文档。

XQuery and XPointer are both built on XPath expressions. XQuery 1.0 and XPath 2.0 share the same data model and support the same functions and operators.
XQuery和XPointer都建立于XPath表达式。XQuery 1.0 和 XPath 2.0共享相同的数据模型并支持相同的函数和操作

——————————————————————————–

XPath is a W3C Standard
XPath是W3C标准
XPath became a W3C Recommendation 16. November 1999.
XPat于1999年11月16日成为W3C的推荐标准

XPath was designed to be used by XSLT, XPointer and other XML parsing software.
XPath被设计成为用语XSLT,XPoniter以及其他XML解析的软件。

昨天在写类的时候,遇到了一个问题,就是如何在类中引用form里面控件的问题。我问了几个朋友,但是给出的方法都存在问题。下面是刘工给我的一个解决办法。

1。首先需要在Program.cs里面,main()函数以外,声明如下语句:

```
public static Form1 frmMain;
```

通常在main()函数之上。

昨天在写类的时候,遇到了一个问题,就是如何在类中引用form里面控件的问题。我问了几个朋友,但是给出的方法都存在问题。下面是刘工给我的一个解决办法。

1。首先需要在Program.cs里面,main()函数以外,声明如下语句:

程序代码 程序代码
public static Form1 frmMain;
通常在main()函数之上。
2。在main()函数内声明如下语句

3。在win app窗体内将需要传递值的控件的modifiers属性改为Public,因为只有是public访问修饰符时,才可以在任何地方访问。
4。在类中调用控件值。使用下面的代码:

程序代码 程序代码
Program.frmMain.txtBox1.Text…..
代码仅供参考,如果哪位朋友有更好的方法,我愿闻其详。:-)


昨天下午看了一部很感人的电影,不是并不是因为人,而是狗,8只英勇的西伯利亚雪橇犬在人类留下的150多天里,它们依靠勇气,团结,关爱坚强存活下来的故事。

据说是根据1957年的真实故事改编。但是我还没有从Google上搜索到,赫赫,也许我搜索的关键字不正确。影片中给我映像最深的一只狗是叫maya的雪橇犬,它是这个小团队的领导者,不放弃伙伴,团队觅食。

如果要给影片打分的话,我打9分。电影真实的再现了冰川地貌,还有南极特有的极光现象,冰川动物,很不错,可见导演在环境上下足了功夫,努力给大家展现一个“绝处逢生”的景象。

不过最让人喜欢的还是片中那8只可爱的西伯利亚雪橇犬。我特地在网络上搜索了一下小明星的档案,现摘抄如下:


哈士奇
Siberian Husky,西伯利亞雪橇犬,台灣叫哈士奇。毛較綿密較厚,主要特徵是尾巴下垂,兩耳在頭頂較近,耳尖向正上方。個性溫和。

西伯利亚哈士奇(siberian husky)是原始的古老犬种,名字的由来是源自哈士奇独特的嘶哑叫声。在西伯利亚东北部的原始部落楚克奇族(Chukchi)人,用这种外型酷似狼的犬种作为最原始的交通工具来拉雪橇,并用这种狗猎取和饲养驯鹿,或者繁殖这种狗然后带出他们居住的冻土地带来换取温饱。由于哈士奇体型小巧结实,胃口小,无体臭且耐寒非常适应极地的气候环境,而成为楚克奇人的重要财产。

1909年由一个俄国的皮毛商人”william goosak”带第一队这种楚克奇族人的狗到了阿拉斯加一个叫”nome”的小镇来参加当地举办的狗拉雪橇比赛。这种楚克奇族人的狗以超快的速度和坚韧的毅力开始被当地的狗拉雪橇爱好者而喜爱。从此以后这些拥有着小而紧凑身材的美丽犬种开始在阿拉斯加被当地人所认可。

1925年1月阿拉斯加偏僻小镇nome白喉流行,由于最近存有血清的城市远在955英里以外,当运送血清至离nome 657英里的地方本有直升机可供运送,但是刚巧直升机驾驶回内地休假且无人能架直升机。为了快速运回治疗白喉的血清,决定用哈士奇雪橇队代替运送,657英里的路程照当时正常的运送速度来算差不多需要25天时间,由于病症快速蔓延,接受任务的雪橇队决定以接力运送的方式运送血清,在雪橇队全力以赴的前提下,只用了5天半时间就完成了任务,挽救了无数的生命。为当时领队的头狗togo已经十多岁了,长途跋涉后由于腿部受伤而退出雪橇比赛,并于1929年死亡,遗体存放在美国国家博物馆,纽约中央公园设有togo的纪念碑,供后人瞻仰。

哈士奇虽然很早就到达了美国,但是美国纯种狗俱乐部(the American kennel club)却到1930年才正式编哈士奇入纯种狗行列,并制定了犬种标准。后来一些美国的哈士奇犬友又在1938成立了美国哈士奇俱乐部(siberian husky culb of American)简称SHCA,从此哈士奇真正的开始被全世界所接受。

各位爱狗的朋友,肯定不会错过一个这样的机会吧。

今天下午把昨天学的东西,实践了一下。写了一个简单的2个数字的加减乘除计算器。

代码已经上传到了网络硬盘里面,有兴趣的初学者可以看看,我本来想声明一个全局变量,后来搜索了一下MSDN,发现C#是没有全局变量的,就老老实实地在每个事件里面声明。虽然笨拙一点,但是保险。

也希望高手指点一二。呵呵。

private void button1_Click(object sender, EventArgs e)  
        {  
            //加法运算  
            Double x, y, result;  
            x = Convert.ToDouble(txtUsr.Text);  
            y = Convert.ToDouble(txtPwd.Text);  
            result = x + y;  
            MessageBox.Show(result.ToString());  
        }</textarea>

        private void button2_Click(object sender, EventArgs e)  
        {  
           //点击reset复位所有文本框内容  
            txtUsr.Text = “”;  
            txtPwd.Text = “”;  
        }

        private void button6_Click(object sender, EventArgs e)  
        {  
            //点击QUIT退出程序  
            Application.Exit();  
        }

        private void button3_Click(object sender, EventArgs e)  
        {  
            //减法运算  
            Double x, y, result;  
            x = Convert.ToDouble(txtUsr.Text);  
            y = Convert.ToDouble(txtPwd.Text);  
            result = x – y;  
            MessageBox.Show(result.ToString());  
        }

        private void button4_Click(object sender, EventArgs e)  
        {  
            Double x, y, result;  
            x = Convert.ToDouble(txtUsr.Text);  
            y = Convert.ToDouble(txtPwd.Text);  
            result = x * y;  
            MessageBox.Show(result.ToString());  
        }

        private void button5_Click(object sender, EventArgs e)  
        {  
            //除法,因为除数为0没有意义,所以用了条件语句  
            Double x, y, result;  
            x = Convert.ToDouble(txtUsr.Text);  
            y = Convert.ToDouble(txtPwd.Text);  
            if (y == 0)  
            {  
                MessageBox.Show(“Sorry,there is an error!”);  
            }  
            else  
            {  
                result = x / y;  
                MessageBox.Show(result.ToString());  
            }  
        }