user1701252
user1701252

Reputation: 1571

Xpath - Exclude elements within TD

I'm trying to use Chrome's scraper extension using XPath. I've been able to scrape everything I need from a table, but I'm stuck in one spot. Here's the source

<td>
<p class="pClass">
    <a href="theurl" target="_blank">
        <i class="iClass">someText</i>
    Anchor text
    </a>
</p>
</td>

I'm trying to grab just the URL, but when using my Xpath code as td[9]/p/a it grabs the icon part that says "someText". Is there a way to just grab the URL?

Upvotes: 1

Views: 97

Answers (1)

vold
vold

Reputation: 1549

In order to extract url just add @href to your xpath expression, this should work: //td[9]/p/a/@href. For stripping white space you can use xpath function normalize-space().

Upvotes: 1

Related Questions