5 replies [Last post]
Tyssen
Tyssen's picture
User offline. Last seen 7 hours 29 min ago. Offline
rank Moderator
Moderator
Timezone: GMT+10
Joined: 2004-05-01
Posts: 7411
Points: 509

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, post ALL your code, both HTML & CSS. No server-side code; just the code sent to the browser.
Use tags.
My articles | CSS Reference

Tags:
ljbailey
ljbailey's picture
User offline. Last seen 3 hours 45 min ago. Offline
rank Enthusiast
Enthusiast
Timezone: GMT+1
Joined: 2009-01-10
Posts: 220
Points: 55

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 can make web pages look exactly how he wants using CSS, and learns a little more every site he codes. You can view his latest design for his SEO Copywriting services company, and the latest design he has done, which is for the company blog.

Tyssen
Tyssen's picture
User offline. Last seen 7 hours 29 min ago. Offline
rank Moderator
Moderator
Timezone: GMT+10
Joined: 2004-05-01
Posts: 7411
Points: 509

Yep, js.

Yep, js.

How to get help
Post a link. If you can't post a link, post ALL your code, both HTML & CSS. No server-side code; just the code sent to the browser.
Use tags.
My articles | CSS Reference

acluett
acluett's picture
User offline. Last seen 29 weeks 3 days 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 26 min ago. Offline
rank Moderator
Moderator
Timezone: GMT+10
Joined: 2003-03-12
Posts: 3215
Points: 522

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 7 hours 29 min ago. Offline
rank Moderator
Moderator
Timezone: GMT+10
Joined: 2004-05-01
Posts: 7411
Points: 509

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, post ALL your code, both HTML & CSS. No server-side code; just the code sent to the browser.
Use tags.
My articles | CSS Reference