Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • It's possible, but I'm not sure how to handle multiple predicates. For the simple case, it looks like this:

    "div[/*/span[@class='storyicons']]"

    which pulls out all the divs which have a grandchild which is a span with a class of 'storyicons'.

    • You can put multiple predicates on a single path step. Something like /foo[@bar='baz'][@quux='qux'] is completely valid (and logically equivalent to /foo[@bar='baz' and @quux='qux']).

      • ah!

        So in the example above, it would be something like

        "//div[@class='full'][.//div/div[@class='details']/a[@href='"+href+"']]"

        (I think)

        • Yes; or alternatively:

          "//div[@class='full' and .//div/div[@class='details']/a[@href='"+href+"']]"

        • Err, wait, no. Where did that .// in your second predicate come from? It would be either

          "//div[@class='full'][div/div[@class='details']/a[@href='"+href+"']]"

          or

          "//div[@class='full' and div/div[@class='details']/a[@href='"+href+"']]"

          You want those nested DIVs and As as direct child nodes of each other and of the node in question – you’re not looking for that subtree anywhere further down.