document.evaluate

Returns an XPathResult based on an XPath expression and other given parameters.

Syntax

var xpathResult = document.evaluate(
 xpathExpression, 
 contextNode, 
 namespaceResolver, 
 resultType, 
 result);

  • xpathExpression is a string representing the XPath to be evaluated.
  • contextNode specifies the context node for the query (see the [http://www.w3.org/TR/xpath XPath specification). It's common to pass document as the context node.
  • namespaceResolver is a function that will be passed any namespace prefixes and should return a string representing the namespace URI associated with that prefix. It will be used to resolve prefixes within the XPath itself, so that they can be matched with the document. null is common for HTML documents or when no namespace prefixes are used.
  • resultType is an integer that corresponds to the type of result XPathResult to return. Use named constant properties, such as XPathResult.ANY_TYPE, of the XPathResult constructor, which correspond to integers from 0 to 9.
  • result is an existing XPathResult to use for the results. null is the most common and will create a new XPathResult

 

Example

From the Mozilla XPath Tutorial:

   var headings = document.evaluate("//h2", document, null, XPathResult.ANY_TYPE, null);   
   /* Search the document for all h2 elements.   
    * The result will likely be an unordered node iterator. */  
   var thisHeading = headings.iterateNext();   
   var alertText = "Level 2 headings in this document are:\n";  
   while (thisHeading) {  
     alertText += thisHeading.textContent + "\n";  
     thisHeading = headings.iterateNext();  
   }  
   alert(alertText); // Alerts the text of all h2 elements  

 

Notes

  • XPath expressions can be evaluated on HTML and XML documents.
  • While using document.evaluate() works in FF2, in FF3 one must use someXMLDoc.evaluate() if evaluating against something other than the current document.

Result types

(Merge with Template:XPathResultConstants?

These are supported values for the resultType parameter of the evaluate method:

Result Type Value Description
ANY_TYPE 0 Whatever type naturally results from the given expression.
NUMBER_TYPE 1 A result set containing a single number. Useful, for example, in an XPath expression using the count() function.
STRING_TYPE 2 A result set containing a single string.
BOOLEAN_TYPE 3 A result set containing a single boolean value. Useful, for example, an an XPath expression using the not() function.
UNORDERED_NODE_ITERATOR_TYPE 4 A result set containing all the nodes matching the expression. The nodes in the result set are not necessarily in the same order they appear in the document.
ORDERED_NODE_ITERATOR_TYPE 5 A result set containing all the nodes matching the expression. The nodes in the result set are in the same order they appear in the document.
UNORDERED_NODE_SNAPSHOT_TYPE 6 A result set containing snapshots of all the nodes matching the expression. The nodes in the result set are not necessarily in the same order they appear in the document.
ORDERED_NODE_SNAPSHOT_TYPE 7 A result set containing snapshots of all the nodes matching the expression. The nodes in the result set are in the same order they appear in the document.
ANY_UNORDERED_NODE_TYPE 8 A result set containing any single node that matches the expression. The node is not necessarily the first node in the document that matches the expression.
FIRST_ORDERED_NODE_TYPE 9 A result set containing the first node in the document that matches the expression.

Results of NODE_ITERATOR types contain references to nodes in the document. Modifying a node will invalidate the iterator. After modifying a node, attempting to iterate through the results will result in an error.

Results of NODE_SNAPSHOT types are snapshots, which are essentially lists of matched nodes. You can make changes to the document by altering snapshot nodes. Modifying the document doesn't invalidate the snapshot; however, if the document is changed, the snapshot may not correspond to the current state of the document, since nodes may have moved, been changed, added, or removed.

Specification

DOM Level 3 XPath

 

Flex 通用调试工具(ff,chrome,ie8+)

如题,写了个很傻逼的调试工具,代码很简单,算是满足我的需求了,需要firebug的支持,chrome可以用firebuglite. 至于ie,需要ie8的开发人员工具.好了 上代码

 

package ifree.common.Logging
{
	import flash.external.ExternalInterface;
	public class Logger
	{
		
		public function log(msg:String):void{
			ExternalInterface.call("console.log",msg);
		} 
		public function info(msg:String):void{
			ExternalInterface.call("console.info",msg);
		} 
		public function error(msg:String):void{
			ExternalInterface.call("console.error",msg);
		} 
		public function debug(msg:String):void{
			ExternalInterface.call("console.debug",msg);
		} 
		public function warn(msg:String):void{
			ExternalInterface.call("console.warn",msg);
		} 
		public function _trace(msg:String):void{
			ExternalInterface.call("console.trace",msg);
		} 
	}
}

 

不要扔砖头

用sqlplus备份Oracle 数据库

单表备份(前提库的结构是一样的) 

导出: 
开始钮->运行->输入CMD->进入DOS界面 
EXP 用户名/密码@连接字符串 GRANTS=Y TABLES=(表名) file=C:\文件名.DMP 
导入: 
开始钮->运行->输入CMD->进入DOS界面 
IMP 用户名/密码@连接字符串 IGNORE=Y TABLES=(表名) FULL=N file=C:\文件名.DMP 

全库导 
导出: 
开始钮->运行->输入CMD->进入DOS界面 
EXP 用户名/密码@连接字符串 FULL=Y file=C:\文件名.DMP 
导入: 
开始钮->运行->输入CMD->进入DOS界面 

 

vim中删除技巧

:%s/[Ctrl-v][Enter]//g 删除DOS方式的回车^M
:%s= *$== 删除行尾空白
:%!sort -u 删除重复行
:%s/^.{-}pdf/new.pdf/ 只是删除第一个pdf
:%s/// 删除多行注释
:g/^$/d 删除所有空行 
:g!/^dd/d 删除不含字符串'dd'的行
:v/^dd/d 删除不含字符串'dd'的行
:g/str1/,/str2/d 删除所有第一个含str1到第一个含str2之间的行
:v/./.,/./-1join 压缩空行
:g/^$/,/./-j 压缩空行
ndw 或 ndW 删除光标处开始及其后的 n-1 个字符。
d0 删至行首。
d$ 删至行尾。
ndd 删除当前行及其后 n-1 行。
x 或 X 删除一个字符。
Ctrl+u 删除输入方式下所输入的文本。
D 删除到行尾
x,y 删除与复制包含高亮区
dl 删除当前字符(与x命令功能相同)
d0 删除到某一行的开始位置
d^ 删除到某一行的第一个字符位置(不包括空格或TAB字符)
dw 删除到某个单词的结尾位置
d3w 删除到第三个单词的结尾位置
db 删除到某个单词的开始位置
dW 删除到某个以空格作为分隔符的单词的结尾位置
dB 删除到某个以空格作为分隔符的单词的开始位置
d7B 删除到前面7个以空格作为分隔符的单词的开始位置
d) 删除到某个语句的结尾位置
d4) 删除到第四个语句的结尾位置
d( 删除到某个语句的开始位置
d) 删除到某个段落的结尾位置
d{ 删除到某个段落的开始位置
d7{ 删除到当前段落起始位置之前的第7个段落位置
dd 删除当前行
d/text 删除从文本中出现“text”中所指定字样的位置,一直向前直到下一个该字样所出现的位置(但不包括该字样)之间的内容
dfc 删除从文本中出现字符“c”的位置,一直向前直到下一个该字符所出现的位置(包括该字符)之间的内容
dtc 删除当前行直到下一个字符“c”所出现位置之间的内容
D 删除到某一行的结尾
d$ 删除到某一行的结尾
5dd 删除从当前行所开始的5行内容
dL 删除直到屏幕上最后一行的内容
dH 删除直到屏幕上第一行的内容
dG 删除直到工作缓存区结尾的内容
d1G 删除直到工作缓存区开始的内容

ref:wiki.ubuntu.org.cn/UbuntuSkills#unzip_.E4.B8.AD.E6.96.87.E6.96.87.E4.BB.B6.E5.90.8D.E4.B9.B1.E7.A0.81

Flex的MXML文件结构

       下面是一个MXML

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx=http://www.adobe.com/2006/mxml layout="absolute">

   

</mx:Application>

 

第一行声明XML文件采用的语法版本号和文件采用的编码格式。mx:Application标签是一个特殊的标签。在每一个MXML文件,但作为程序入口的运行文件只有一个,主文件的标示是根节点为mx:Application,一个程序中出现一个mx:Application节点。还有一个属性xmlns:mx=http://www.adobe.com/2006/mxml表示将mx定义为XML的命名空间。xmlns标签专门用来定义XML的命名空间,XML命名空间可以用来定义一套独立的XML标签,并且为这些标签指定特殊的解析方式。比如XML文件中默认的标签格式为:<Button>node</Button>,这里的Button节点作为一个普通的文本节点,没有特殊的意义。定义命名空间后,在节点上加上空间前缀:<mx:Button></mx:Button>这时候就代表mx空间下的Button对象。

Mx命名空间对应的路径是”http:// www.adobe.com/2006/mxmlFlex的配置文件中将这个路径定义为一个全局资源标识符,并对应了一个XML文件。在这个文件中,列出了mx命名空间下的所有标签。在Flex SDK3.0.1 目录下的frameworks目录中找到flex-config.xml文件,打开并找到如下内容:

 

<namespaces>

     <namespace>

            <uri>http://www.adobe.com/2006/mxml</uri>

            <manifest>mxml-manifest.xml</manifest>

     </namespace>

</namespaces>

 

从上面可以发现,http://www.adobe.com/2006/mxml”这个URImxml-manifest.xml文件对应,打开该文件,该文件列出了MXML中的所有标签与标签关联的类文件路径。

<?xml version="1.0"?>

 

<componentPackage>

 

   <component id="FileSystemComboBox" class="mx.controls.FileSystemComboBox"/>

<component id="FileSystemDataGrid" class="mx.controls.FileSystemDataGrid"/>

      。。。。。。。

<component id="WebService" class="mx.rpc.soap.mxml.WebService"/>

<component id="WebServiceOperation" class="mx.rpc.soap.mxml.Operation"/>

 

</componentPackage>

 

 

在开发中,当程序有很多MXML文件和AS文件时,为了方便调用,我们可以将功能相似的文件放在一个文件夹中,定义一个命名空间在定义命名空间时,为了方便,很一般直接指定命名空间包括的标签路径。比如:

xmlns:myComp=”components.*”

上面使用了通配符”*” components目录下所有的MXML文件个ActionScript类文件都被包括在myComp命名空间下。例如components中有一个Loginpanel.mxml,则程序中调用这个文件时,代码如下

<myComp: Loginpanel></myComp: Loginpanel>

myComp下的标签被自动指向components文件,当标签数量较多而且分布在不同文件夹时,可以效仿Flex配置文件的做法,使用XML文件来描述。

ref:hi.baidu.com/flexok/blog/item/83397ca93c70dc044a36d61b.html