Today, a co-worker came asking me if there was an easy way to do this task: he needed to create an array of strings from a HTML structure composed of a top level div (with an id), with child divs, each containing a bunch of uls, which in turn contained a bunch of lis that contained a span with the desired text, plus anchor tags, among other non-relevant stuff.
We use prototype, so I scribbled a quick script using it:
var a = []; $$("#bla div ul li span").each(function(e) { a.push(e.innerHTML) })
He tried it out and it worked like a charm.
I love problems that take longer to describe than to solve :)
No comments:
Post a Comment