Hello

 

I am using XPath as a way of dissecting web pages, especially from
Wiktionary. Generally I get good results, but I could get useful extra
flexibility by using the binary Smalltalk operators to represent XPath, as
mentioned at the end of the class comment for XPath. However, the
description there is very terse, and I am having difficulty seeing how to
include more complex expressions, especially attribute tests. I have put
some of my XPath expressions through the XPath compiler and looked at the
output, and out of that I have found expressions which work but look very
clumsy. As an example, I have used the fragment:

 

document xPath: '//div[@id=''catlinks'']//li//text()'

 

and found that an equivalent is:

 

document //'div' ?? [:node :x :y|(node attributeAt: 'id') =
'catlinks']//'li'//[:n| n isStringNode]].

(I had to put two dummy arguments in the three-argument block to get it to
work.) 

 

Is there a more extensive explanation of the use of these binary operators?
If not, could some kind person show me the most concise translation of the
sample XPath above, to give me a start in working out more complex cases?

 

Many thanks for any help.

 

Peter Kenny

 

Reply via email to