1

how do I select a <td> </td> that is empty or ONLY contains white spaces no matter how many with XPATH in PHP?

I'd like to replace the two not(text()) in the code underneath in order to not only match no text but also white spaces.

//tr[td[1][contains(text(), "'. $match .'")]] /following-sibling::tr[td[1][not(text())] and preceding-sibling::tr[1][td[1][not(text()) or contains(text(), "'. $match .'")]]]

  • http://codepad.org/ALBcpGew – Gordon Nov 03 '13 at 16:15
  • replacing it for `not(text())`in the example underneath gives me an error… `//tr[td[1][contains(text(), "'. $match .'")]] /following-sibling::tr[td[1][not(text())] and preceding-sibling::tr[1][td[1][not(text()) or contains(text(), "'. $match .'")]]] ` – user2944979 Nov 03 '13 at 16:23
  • you are aware that your example is quite different from "selecting only nodes with whitespace", are you? – Gordon Nov 03 '13 at 16:25
  • You are right! I never said "selecting only whitespaces"! I want to select the ones containing nothing or whitespaces but noText. UPDATED the question to make things more clearly! So this is definitely not a duplicate of the question you linked to mine… I already came across that one and it didn't help me solving the problem. Therefore I'm asking to remove the link please. – user2944979 Nov 03 '13 at 21:31
  • I don't understand your question. The linked dupe answers "how do I select a that is empty or ONLY contains white spaces". The linked codepad example shows that it does. Consider providing a sample XML and the nodes you want to match from it. Consider http://meta.stackexchange.com/questions/156810/stack-overflow-question-checklist – Gordon Nov 04 '13 at 10:29

0 Answers0