<div>
<div class="dates">
所以,为了找到上面的日期类,我使用$x("//div[@class= 'dates']//")
但是控制台说这个表达式是非法表达。
<div class="bx-wrapper" style="max-width: 870px; margin: 0px auto;">
<div class="bx-viewport" style="width: 100%; overflow: hidden; position: relative; height: 0px;">
<div class="bx-wrapper" style="max-width: 870px; margin: 0px auto;">
<div class="bx-viewport" style="width: 100%; overflow: hidden; position: relative; height: 91px;">
<ul id="DateList" class="bxslider clearfix" data-bx-slider="mode: 'horizontal', pager: false, controls: false, minSlides: 1, maxSlides:4, slideWidth: 290, slideMargin:0, hideControlOnEnd:true, infiniteLoop: false, moveSlides: 1" style="width: 515%; position: relative; transition-duration: 0s; transform: translate3d(0px, 0px, 0px);">
要找到上述节点的正确xpath,我使用$ x(&#34; // ul [@ id =&#39; DateList&#39;] //&#34;)和仍有消息说表达是非法的。
<li class="date-block slide ng-scope" data-notify-when-repeat-finished="" ng-repeat="dates in cruiseFinder.filters.sailDates" style="float: left; list-style: outside none none; position: relative; width: 290px;">
<h5 class="ng-binding">2015</h5>
<ul id="months" class="months">
答案 0 :(得分:0)
在这两种情况下,最后一个双斜线太多:正确的xpath将是:
//div[@class= 'dates']
//ul[@id= 'DateList']
双斜线到xpath表达式意味着“在文档的任何位置”。