2009-08-27 108 views
1

在iphone上移动safari支持xpath吗?我正在使用libxml2来解析objective-c中的xhtml文件,但希望能够即时更改我的解析逻辑。正在考虑使用UIWebview的stringByEvaluatingJavaScriptFromString:方法。在iphone上移动safari支持xpath吗?

回答

0

我看到版本3.0有document.evaluatehttps://developer.mozilla.org/en/DOM/document.evaluate这就是XPATH评估所需的全部内容。

+0

document.evaluate在Simulator 3.0或Simulator 3.1中不起作用。 我在webViewDidFinishLoad中运行以下内容,其中加载的页面有2

个元素,并且评估结果为零。 (“\”计数(//表单)\“,document,null,XPathResult.STRING_TYPE,null).stringValue;”; result = [thewebView stringByEvaluatingJavaScriptFromString:scriptCode]; – user158678 2009-09-09 09:22:54

+0

您是否尝试过使用'snapshotLength',而不是xpath的'count'? 'document.evaluate(“// form”,document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null).snapshotLength' – kangax 2009-09-09 14:33:06