Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
谁能帮助我使用 xpath 选择器来选择pre页面中的所有标签,但前提是它们不在另一个pre标签中?(即使多层次深)
pre
如果这一切都可以在一个选择器中完成,而不是仅仅选择所有pre标签并在它们pre作为父标签时中断,那就太棒了。
像这样?//pre[not(ancestor::pre)]
//pre[not(ancestor::pre)]
或者为了完整起见,在 XPath 2.0 中
//pre except //pre//pre
尝试: