XPath to a Text item with no text?

Ask general questions here.
User avatar
Aracknid
Posts: 342
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

XPath to a Text item with no text?

Post by Aracknid » Thu Jun 09, 2011 9:04 pm

I'm walking through a table's rows looking for cells in a specific column whose text value is nothing (blank, or no text has yet been entered). How can I do this? Here's what I tried and it is not working (error in code or no match in Spy)

So this works here:

Code: Select all

...../Table/element/element/element[4]/text 
It returns a rows cell 4 text object, which may or may not contain text, but I only want it if it actually has no text so I tried this:

Code: Select all

...../Table/element/element/element[4]/text[@text='']
And it doesn't work. It would work if I did this,

Code: Select all

...../Table/element/element/element[4]/text[@text='Aracknid']
so that's why I figured I could put nothing in between the single quote chars.

How do I achieve this with an XPath?

Thanks,

Aracknid

User avatar
Aracknid
Posts: 342
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: XPath to a Text item with no text?

Post by Aracknid » Thu Jun 09, 2011 9:08 pm

Figures, the moment you post, you almost always figure it out on your own...

I just needed to do this:

Code: Select all

...../Table/element/element/element[4]/text[@text=null()]