taoqf / node-html-parser

A very fast HTML parser, generating a simplified DOM, with basic element query support.
MIT License
1.12k stars 112 forks source link

how do I select the middle td? #59

Closed working-name closed 3 years ago

working-name commented 4 years ago

Here's my .structure

'tr
  td
    div
      span
        #text
      p
        #text
      p
        #text
  td
    #text
  td
    span
      #text'

Trying to get the second td. I tried all I could think of... no go. Is this even implemented?

hp4k1h5 commented 3 years ago

i think you want something like

root.querySelector('tr td:nth-child(2)')

actually this feature may not be implemented https://github.com/taoqf/node-html-parser/issues/74

taoqf commented 3 years ago

I would say maybe you should querySelectorAll, and then filter the result array. Good luck.