madeindjs/Crystagiri

Xpath example?

Closed this issue · 2 comments

Hello thanks for your hard work. Is there any find by xpath example? I cant find.

Also how can I find subtags under a tag? For example there is six td tag under tr tag; I want to select them and read its content.

Thanks!

I prefer to use CSS selectors:

doc.css("tr td") do |td|
  ...
end

For xpath, you should directly use XML::Node in standard librairy. You can find some examples in Crystal Documentation.

About you CSS query, @grig191 's answer seem good .