On Feb 11, 5:29 pm, [email protected] wrote:
I’d rather use Ruby.
Would you use Ruby string functions instead of the regular expression?
You could, but you probably wouldn’t want to. XPath is like regular
expressions for XML and HTML. It has a particular syntax but once you
learn it, it’s very powerful.
// is quite cryptic.
It’s the wildcard in XPath. So ‘//td’ just means the td can be
anywhere in the tree, as opposed to ‘/td’ which would be at the root.
It’s no more cryptic than the .* wildcard in regexps.
td[contains(.,“Traffic Left”)]
The square braces constrain the td with an expression that compares
the current td node (that’s what the . means) to the string “Traffic
Left”. So this phrase says select the
string.
following-sibling::td//script
This says find the tag under the next (in document order)
XPath isn’t hard to learn. And it’s well worth the investment.