我正在创建一个xpath,但是我在xpath输出中有空格。我尝试使用normalize-space,但是没有用。
((//a[contains(@class,'product-name')])[3])[normalize-space()='Printed Dress']
<div class="product-container" itemscope itemtype="http://schema.org/Product">
<div class="left-block">
<div class="product-image-container">
<a class="product_img_link" href="http://automationpractice.com/index.php?id_product=3&controller=product" title="Printed Dress" itemprop="url">
<img class="replace-2x img-responsive" src="http://automationpractice.com/img/p/8/8-home_default.jpg" alt="Printed Dress" title="Printed Dress" width="250" height="250" itemprop="image" />
</a>
<div class="quick-view-wrapper-mobile">
<a class="quick-view-mobile" href="http://automationpractice.com/index.php?id_product=3&controller=product" rel="http://automationpractice.com/index.php?id_product=3&controller=product">
<i class="icon-eye-open"></i>
</a>
</div>
<a class="quick-view" href="http://automationpractice.com/index.php?id_product=3&controller=product" rel="http://automationpractice.com/index.php?id_product=3&controller=product">
<span>Quick view</span>
</a>
<div class="content_price" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<span itemprop="price" class="price product-price">
$26.00 </span>
<meta itemprop="priceCurrency" content="USD" />
</div>
</div>
</div>
我希望输出仅显示为“ Printed Dress”,但输出为
Printed Dress
答案 0 :(得分:0)
normalize-space
是一个xpath函数,它将在评估xpath而不是输出时修剪空白。
您必须使用特定于语言的方法来修剪输出。例如:如果您使用的是python,则可以使用outPut.strip()
。