5 replies [Last post]
Tyssen
Tyssen's picture
User offline. Last seen 1 day 10 hours ago. Offline
rank Moderator
Moderator
Timezone: GMT+10
Joined: 2004-05-01
Posts: 8123
Points: 1302

I'm trying to modify this:

"//tr|//tr//descendant::text()",

so that it doesn't search for whole table rows, but rather just the third cell in table rows. I thought it would be:

"//tr/td[3]|//tr/td[3]//descendant::text()",

but that's not it.

By the way this is from a Greasemonkey script which matches an array of keywords against the contents of the element that XPath is searching which is why I want to modify it because at the moment it's filtering out too many rows.

How to get help
Post a link. If you can't post a link, jsFiddle it.
My blog | My older articles | CSS Reference

Tags:
ljbailey
ljbailey's picture
User offline. Last seen 1 year 12 weeks ago. Offline
rank Enthusiast
Enthusiast
Joined: 2009-01-10
Posts: 224
Points: 59

Just to clarify, this is you

Just to clarify, this is you trying to edit an application of Xpath in Js and not in CSS - correct?

Liam Bailey is director of Galloway Web Services, a Stranraer web design company, sister of SEO copywriting services company Write About Property.

Tyssen
Tyssen's picture
User offline. Last seen 1 day 10 hours ago. Offline
rank Moderator
Moderator
Timezone: GMT+10
Joined: 2004-05-01
Posts: 8123
Points: 1302

Yep, js.

Yep, js.

How to get help
Post a link. If you can't post a link, jsFiddle it.
My blog | My older articles | CSS Reference

acluett
acluett's picture
User offline. Last seen 1 year 52 weeks ago. Offline
newbie
Timezone: GMT+5.5
Joined: 2010-02-08
Posts: 2
Points: 3

Is this necessary if you

Is this necessary if you still tell the browsers to parse the page as HTML? I know it's not valid according to the W3C validator, but what's important is not that the page validates there but rather that the code is valid.

Tony
Tony's picture
User offline. Last seen 6 hours 16 min ago. Offline
rank Moderator
Moderator
Timezone: GMT+10
Joined: 2003-03-12
Posts: 3705
Points: 1115

Hi Tyssen, I haven't looked

Hi Tyssen,
I haven't looked at xpath before but the quick look I just had seems to suggest it should be:

//tr/td[position()=3]//descendant::text()

Your question may have already been answered, search and read before you ask.

Tyssen
Tyssen's picture
User offline. Last seen 1 day 10 hours ago. Offline
rank Moderator
Moderator
Timezone: GMT+10
Joined: 2004-05-01
Posts: 8123
Points: 1302

Thanks Tony, that looks like

Thanks Tony, that looks like it might've done the trick.

How to get help
Post a link. If you can't post a link, jsFiddle it.
My blog | My older articles | CSS Reference