我有一个HTML文档,我愿意找出包含某个字符串的元素的xpath。
更详细地说:
我的HTML文档是动态创建的,我没有为s指定特定的名称。我感兴趣的div看起来(或多或少)如下所示:
<div>Country: China</div>
<div>Type: Earphones</div>我想要得到整个字符串"Country: China“。为此,我想通过在HTML中搜索"Country:“来找到这个div的xpath。
我希望我说得够具体..。谢谢!
发布于 2012-05-08 07:40:31
以下是几种方法:
//div[contains(child::text(), "Country:")]
//div/child::text()[contains(., "Country:")]/parent::node()如果你想在浏览器中尝试,那就试试in-browser XPath bookmarklet吧。
https://stackoverflow.com/questions/10490442
复制相似问题