Marc
Marc

Reputation: 113

XPATH extract text within <br>

I am practicing with XPATH to extract text within HTML.

I have the following structure:

<tbody>
  <tr class="table-row">
    <td class="table-cell">
        Name
        <br />
        Address
        <br />
        Postcode
        <br />
        Phone: 111111
        <br />
        Fax:  123456
        <br />
        Email:  <a class="mail" href="mailto:mail@example.com">mail@example.com</a>
        <br />
    </td>
  </tr>
  <tr class="table-row">
    <td class="table-cell">
        Name
        <br />
        Address
        <br />
        Postcode
        <br />
        Phone: 111111
        <br />
        Fax:  123456
        <br />
        Email:  <a class="mail" href="mailto:mail@example.com">mail@example.com</a>
        <br />
    </td>
  </tr>
  (...)
</tbody>

I manage to navigate different nodes but I can't figure out how to extract within a text node.

In particular, I need to extract text within "Phone:" and following <br /> and "Email:" and following <br /> in all rows in the table.

Upvotes: 0

Views: 126

Answers (1)

becixb
becixb

Reputation: 373

how about //td/text()[4] for Phone and //td/a for the email value

Upvotes: 1

Related Questions