Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 为ImportXML或Xpathonurl函数(Google Sheets或Excel)获取正确的Xpath_Html_Excel_Xpath_Google Sheets - Fatal编程技术网

Html 为ImportXML或Xpathonurl函数(Google Sheets或Excel)获取正确的Xpath

Html 为ImportXML或Xpathonurl函数(Google Sheets或Excel)获取正确的Xpath,html,excel,xpath,google-sheets,Html,Excel,Xpath,Google Sheets,我对这一切都是新手,就我的一生而言,我无法从网上获得有库存或无库存的文本 我尝试过多种变体,但运气不佳。 它是否应该是=importxmlurl,//span[@class='msg'] 使用Excel的xpathonurl函数作为加载项也不起作用 以下是html源代码: <div class="product-avail wgrid-3w6 wgrid-2w4 marg-r-0"> <div class="statuses"> <div class="ship

我对这一切都是新手,就我的一生而言,我无法从网上获得有库存或无库存的文本

我尝试过多种变体,但运气不佳。 它是否应该是=importxmlurl,//span[@class='msg']

使用Excel的xpathonurl函数作为加载项也不起作用

以下是html源代码:

<div class="product-avail wgrid-3w6 wgrid-2w4 marg-r-0"> 
<div class="statuses"> 
<div class="shipping status">
<span class="icon-status checkmark"></span>
<span class="msg">In stock online</span>** </div>
<div class="shipping-alert status">
<span class="icon-status arrow" style="display: inline;"></span>
<span class="msg"><span class="edd"> 
<a href="javascript:void(0)">See estimated delivery date</a></span></span> </div> </div> </div>`
试试这个:

=importxml("url","//span[@class='msg']/text()")
根据xpath,如果要检索给定元素的文本值,应该使用text方法

更新:

给定URL中class=msg的跨度值为空。因此,您可以按如下方式处理N/A:

=IFERROR(IMPORTXML("http://www.walmart.ca/en/ip/large-kick-fetch-ball/6000105718024", "//span[@class='msg']"), "")

谢谢你的回答。不幸的是,我尝试了这个方法,但没有成功:importxml犭url,犭//span[@class='msg']]/text犭Google返回N/A并导入内部错误消息。。。叹气还有其他的建议吗?好的,我看到的是里面没有任何文字。该元素为空。我尝试使用//span[@class='userFirstName'],它完美地返回了值。再次感谢。这是我第一次尝试xpath,并尝试用它做一些有用的事情,所以我也喜欢知道发生了什么。单元格为空与javascript有关吗?如果你点击F12,在它被执行后会显示html或者类似的东西?这有助于解释为什么它是空的吗?对于您与IFERROR的解决方案。。。我需要输出说明它是否有库存,并自动更新,所以我不知道这有什么帮助。但也可能是我,就像我说的,我是所有这些的新手。看。我用我学到的知识和当前的障碍更新了这个问题。