Flash的XPathAPI类(二)

XPathAPI.getEvalString()方法

译自:flash官方文档 XPathAPI.pdf,译者:Shellway

可用性 (Availability)
自Flash Player 6 (6.0.79.0).

版本 (Edition)
Flash MX 2004.

用法 (Usage)
XPathAPI.getEvalString(node, path)

参数 (Parameters)

node 一个XML节点;语句执行开始处的父DOM节点的索引;
An XML node; a reference to the DOM node that is the parent node from which the statement executes.

path 一个识别XML节点树路径的字符串;
A string identifying the path through the XML node hierarchy.

返回值 (Returns)
一个字符串,表示从父节点访问路径参数指定的的值所需的代码。
A string that represents the code required to access the value specified by the path parameter from the parent node.

描述 (Description)
方法;针对指定节点,获取交互得到的估值字符串;
Method; for a specified node, gets the corresponding evaluation string.

示例 (Example)
下面的示例代码会在输出面板中显示用于指定节点的估值字符串:
The following example displays the corresponding evaluation string used for a specified node
in the Output panel:

//导入XPathAPI类。
import mx.xpath.XPathAPI;

var rssfeed_xml:XML = new XML();
rssfeed_xml.ignoreWhite = true;
rssfeed_xml.onLoad = function(success:Boolean) {
trace("onload...");
if (success) {
trace("success...");
// 获取/rss/channel/item中的所有 tittle节点。
// Retrieve all title notes within /rss/channel/item.
var thePath_str:String = "/rss/channel/item";
//获取用于查找的估值字符串。
// Get the evaluation string used for the search.
var myEvalString_str:String = XPathAPI.getEvalString(this.firstChild,
thePath_str);
trace("getEvalString: " + myEvalString_str);
} else {
trace("error loading XML");
}
};
rssfeed_xml.load("http://www.flash-mx.com/news/index.xml");