2009-08-27 53 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