I’ve a bit of challenge that I cannot figure out.
I’ve an HTML doc where a nested iframe host another set of meta tags. I’d like to reach them out via an XPath query, but when testing something like //iframe[.//meta[@name='robots']]
there is no match.
I’ve tried multiple combination by now, without success.
My understanding is that iframe content is normally flattened within the rendered view, hence it should be fully traversable.
In fact a simple .//meta[@name='robots']
works fine.
Reason for asking is to intercept all meta tags in a webpage, while excluding those included in the iFrame.
2
Answers
I'm not sure and clear why this works the other way round than it should be, but eventually the following XPATH does the trick.
Using the page given as the example in the previous comment, editing the rendered HTML to add a testing meta robots in the upper and using the above XPATH returns only that single instance.
It seams like iframe as element is not recognized by Xpath.
Instead you could try for all meta not in iframe: