3

I want to get an td element without attributes.

For example: My code:

<td class="yyy">1234</td>
<td>5678</td>

I want to get: 5678
What the XPath for that?

Thank, Chani

Jodrell
  • 34,946
  • 5
  • 87
  • 124
Chani Poz
  • 1,413
  • 2
  • 21
  • 46

3 Answers3

6

I think this is a duplicate of several other SO questions:

See this:

XPath: How to select nodes which have no attributes?

Which recommends:

//node[not(@*)]

Where node is your nodename.

Community
  • 1
  • 1
Jude Fisher
  • 11,138
  • 7
  • 48
  • 91
1

try the following

  /td[not(@class)]
podiluska
  • 50,950
  • 7
  • 98
  • 104
0

how about

.//td[. = '5678'] 

or

.//td[text() = '5678']

--

if it is important that there are no attributes then,

.//td[text() = '5678' and not(@*)]

--

or, if you want to get the inner text of the first td with no attributes.

.//td[not(@*)][1]/text()
Jodrell
  • 34,946
  • 5
  • 87
  • 124