Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.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
获取xpath div text和next div text的多个结果_Xpath_Yql - Fatal编程技术网

获取xpath div text和next div text的多个结果

获取xpath div text和next div text的多个结果,xpath,yql,Xpath,Yql,使用xpath,我可以一次从一个页面中得到两个结果吗?例如,使用xpath可以获得第一个img元素: xpath='//div[@class="forecast-element graphic-box"]/img …和下一个同级类=“预测元素” 我尝试了“和”,但没有成功: xpath='//div[@class="forecast-element graphic-box"]/img and //div[@class="forecast-element"]' 此外: 我有这个html: &l

使用xpath,我可以一次从一个页面中得到两个结果吗?例如,使用xpath可以获得第一个img元素:

xpath='//div[@class="forecast-element graphic-box"]/img
…和下一个同级类=“预测元素”

我尝试了“和”,但没有成功:

xpath='//div[@class="forecast-element graphic-box"]/img and //div[@class="forecast-element"]'
此外:

我有这个html:

<div class='forecast-element graphic-box ' style="background-image:url('/assets/images/forecast/BluePattern.png');">
    <h4 style="color: #FFF;">AVALANCHE DANGER <span style="margin-left: 60px;"> MORNING </span><span style="margin-left: 210px;"> AFTERNOON</span></h4>
    <img src="/images/forecast/2014-11-23_teton_hazard.gif" alt="Teton Area avalanche hazard rating for 11/23/2014" />
    <div style='margin: 2px auto;'><a href="/assets/pdfs/North%20American%20Danger%20Scale.pdf" style='font-size: 14px; color: #CCC;'>View full danger scale definitions</a>
    </div>
    <a href="/assets/pdfs/North%20American%20Danger%20Scale.pdf" style='font-size: 14px;'>
        <img src="/assets/images/forecast/DangerScale.png" style="margin-left: 150px; margin-top: 5px;" alt='Avalanche danger scale ratings'>
    </a>
</div>

<div class='forecast-element'>
    <h3 style='margin-bottom: 8px;'>GENERAL AVALANCHE ADVISORY</h3>
    Moderate to heavy snowfall combined with strong southwesterly to northwesterly ridgetop winds have created unstable avalanche conditions. New wind slabs have developed at the mid and upper elevations. Snowfall over the past 24 hours has also added weight to existing weak layers near the base of the snowpack. Early season snowfall can easily cloud people’s judgment. Cautious route finding and conservative decision making will be essential for safe travel in avalanche terrain today.</div>

雪崩危险上午下午
一般雪崩咨询
中到大雪,加上西南到西北的脊顶风,造成了不稳定的雪崩条件。在中高海拔地区开发了新的风板。过去24小时的降雪也增加了积雪底部附近现有薄弱层的重量。早期的降雪很容易影响人们的判断。谨慎的路线发现和保守的决策对于今天雪崩地形中的安全旅行至关重要。
我想使用下面的同级,因为项目就在graphic box元素之后,html中还有其他forecast元素。顺便说一句,我正在使用YQL,如果这有区别的话

理想情况下,结果为(此处为psuedo):

xpath imgsrc=“/images/forecast/2014-11-23_teton_hazard.gif”

xpath text=“通用雪崩 建议中到大雪并伴有强降雨 西南至西北……。”


谢谢

选择多个节点的正确语法是
|

试试这个:

//div[@class="forecast-element graphic-box"]/img | //div[@class="forecast-element"]
正如您所提到的,这是两个独立的查询元素。要选择以下元素,只需执行以下操作

//div[@class="forecast-element graphic-box"]/img | //div[@class="forecast-element graphic-box"]/following-sibling::div[@class="forecast-element"]
在某些xpath解析器中,这也会起作用:

//div[@class="forecast-element graphic-box"]/(img|following-sibling::div[@class="forecast-element"])

选择多个节点的正确语法是
|

试试这个:

//div[@class="forecast-element graphic-box"]/img | //div[@class="forecast-element"]
正如您所提到的,这是两个独立的查询元素。要选择以下元素,只需执行以下操作

//div[@class="forecast-element graphic-box"]/img | //div[@class="forecast-element graphic-box"]/following-sibling::div[@class="forecast-element"]
在某些xpath解析器中,这也会起作用:

//div[@class="forecast-element graphic-box"]/(img|following-sibling::div[@class="forecast-element"])

选择多个节点的正确语法是
|

试试这个:

//div[@class="forecast-element graphic-box"]/img | //div[@class="forecast-element"]
正如您所提到的,这是两个独立的查询元素。要选择以下元素,只需执行以下操作

//div[@class="forecast-element graphic-box"]/img | //div[@class="forecast-element graphic-box"]/following-sibling::div[@class="forecast-element"]
在某些xpath解析器中,这也会起作用:

//div[@class="forecast-element graphic-box"]/(img|following-sibling::div[@class="forecast-element"])

选择多个节点的正确语法是
|

试试这个:

//div[@class="forecast-element graphic-box"]/img | //div[@class="forecast-element"]
正如您所提到的,这是两个独立的查询元素。要选择以下元素,只需执行以下操作

//div[@class="forecast-element graphic-box"]/img | //div[@class="forecast-element graphic-box"]/following-sibling::div[@class="forecast-element"]
在某些xpath解析器中,这也会起作用:

//div[@class="forecast-element graphic-box"]/(img|following-sibling::div[@class="forecast-element"])

谢谢,这让我得到了所有的forecast元素类,但是,我只想要下面的兄弟。就在我的forestcast element graphic box课程之后。效果很好。我在同级上添加了[1]以获得下一个。谢谢,这将获得所有预测元素类,但是,我只需要以下同级。就在我的forestcast element graphic box课程之后。效果很好。我在同级上添加了[1]以获得下一个。谢谢,这将获得所有预测元素类,但是,我只需要以下同级。就在我的forestcast element graphic box课程之后。效果很好。我在同级上添加了[1]以获得下一个。谢谢,这将获得所有预测元素类,但是,我只需要以下同级。就在我的forestcast element graphic box课程之后。效果很好。我在兄弟姐妹上添加了[1]以获得下一个。