我有以下html:
<use xlink:href
现在/logo
可以是/logo-filled
或//*[name()='use'][contains(@*='logo')]
如何在Puppeteer中编写xpath表达式以获取这些信息?
我已经尝试过了:
Unable to perform XPath operation. The prefix "xlink" for attribute "xlink:href" associated with an element type "use" is not bound.
但是当我测试它时,我得到了错误:
$_POST = [
'product_id' => 1,
'quantity' => 9
]
答案 0 :(得分:1)
更改
//*[name()='use'][contains(@*='logo')]
^
到
//*[name()='use'][contains(@*,'logo')]
^
或
//use[starts-with(@*,'/logo')]
但关于名称空间,另请参见How does XPath deal with XML namespaces?