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.
考虑这个
Beer <br> Vodka <br> rum <br> whiskey
你会如何在 xpath 中表达 Beer?
/br/preceding-sibling::text() ?
伏特加呢?朗姆酒 ?
取决于上下文。理想情况下,要成为格式良好的 XML,您的序列需要一个根元素。假设它是<bar/>.
<bar/>
啤酒:/bar/br[1]/preceding-sibling::text()[1]
/bar/br[1]/preceding-sibling::text()[1]
伏特加酒: /bar/br[1]/following-sibling::text()[1]
/bar/br[1]/following-sibling::text()[1]
朗姆酒:/bar/br[2]/following-sibling::text()[1]
/bar/br[2]/following-sibling::text()[1]