views:

30

answers:

1
click(new XPath("/HTML[1]/BODY[1]/DIV[1]/DIV[2]/DIV[1]/DIV[2]/DIV[1]/DIV[2]/DIV[1]/DIV[1]/DIV[2]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/DIV[2]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/DIV[2]/DIV[1]/SPAN[1]/SPAN[2]/#text[1]"));

..or

var foo = document.evaluate("/HTML[1]/BODY[1]/DIV[1]/DIV[2]/DIV[1]/DIV[2]/DIV[1]/DIV[2]/DIV[1]/DIV[1]/DIV[2]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/DIV[2]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/DIV[2]/DIV[1]/SPAN[1]/SPAN[2]/#text[1]", document, null, XPathResult.ANY_TYPE,null);

Result to:

[Exception... "The expression is not a legal expression."  code: "51" nsresult: "0x805b0033 (NS_ERROR_DOM_INVALID_EXPRESSION_ERR)"  location: "chrome://chickenfoot/content/chickenscratch.js Line: 2"]

Firefox 3.6, XPath generated by Chickenfoot's XPath generator at GMail's button 'Older'.

What is this kind of XPath and why it is broken?

+1  A: 

There is no #text element. To get the text content, use text(), i.e.

"/HTML[1]/BODY[1]/..../SPAN[2]/text()"
KennyTM