How can I retrieve the table tag using floki, can anyone help me build the selector for this? I spent a lot of time without success trying query this table.
The attribute name is unique so a[name=“myname”] will return just one tag
My last try result in some variations of this selector: a[name=“myname”] +|~|> h4 table
Floki uses a CSS selector to walk through the HTML nodes, but it can also parse the HTML and return a nested list of tuples representing the entire tree of nodes (using parse_document or parse_fragment). You can then walk through those nodes in your own Elixir code to find what you’re looking for.
The :has() pseudoclass does exactly what you’re describing - so in an environment that supports the Selectors Level 4 draft, you could use h4:has(a[name='myname']) + table.
HOWEVER
That’s not supported yet in Floki. Trying it produces a Pseudo-class "has" is not implemented. Ignoring. warning message.