我有以下html:
<button data-testid="likeButton">
<svg aria-hidden="true">
<use xlink:href="/logo"></use>
</svg>
<span>Like</span>
</button>现在,<use xlink:href可以是/logo或/logo-filled
如何在Puppeteer中编写xpath表达式来获得这些内容?
我已经尝试过了:
//*[name()='use'][contains(@*='logo')]但是当我测试它时,我得到了错误:
Unable to perform XPath operation. The prefix "xlink" for attribute "xlink:href" associated with an element type "use" is not bound.发布于 2020-09-28 19:38:48
变化
//*[name()='use'][contains(@*='logo')]
^至
//*[name()='use'][contains(@*,'logo')]
^或
//use[starts-with(@*,'/logo')]但关于名称空间,另请参阅How does XPath deal with XML namespaces?
https://stackoverflow.com/questions/64101297
复制相似问题