Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 25th, 2006, 04:15 PM
Foxpointe
Guest
 
Posts: n/a
Default Using XPath to select TD elements in a table with visible data

I'm new to XPath so am sure my understanding is the issue here and could
use some help....

I've got some fairly messy (X)HTML which has TD elements sprinkled in
solely for the purposes of formatting (i.e. <td height="2"></td>) and
was thinking that I could use XPath to select only the TD nodes which
actually display a value. I've verified the basic path to get all
elements in the table (./html/body/table/tr), but when tried to extend
this with various permutations such as
../html/body/table/tr/td[string-length(text()) 0] without success.

Thanks in advance,
Phil
  #2  
Old July 26th, 2006, 03:35 PM
Richard Tobin
Guest
 
Posts: n/a
Default Re: Using XPath to select TD elements in a table with visible data

In article <78udnRhMcdenqlvZnZ2dnUVZ_vednZ2d@comcast.com>,
Foxpointe <foxpointe@comcast.netwrote:
Quote:
>./html/body/table/tr/td[string-length(text()) 0] without success.
That should work, but you could just use

./html/body/table/tr/td[text()]

since empty ones won't have a text node at all.

-- Richard
  #3  
Old July 27th, 2006, 03:55 AM
Foxpointe
Guest
 
Posts: n/a
Default Re: Using XPath to select TD elements in a table with visible data

Richard Tobin wrote:
Quote:
That should work, but you could just use
>
./html/body/table/tr/td[text()]
>
since empty ones won't have a text node at all.
>
-- Richard
It turns out it did work (user error ;-) but thanks for the tip as I
didn't realize I didn't need to explicitly check the length.

Thanks,
Phil
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles