user633440
user633440

Reputation:

XPath expression to get a string after a <br> tag

I'm trying to get the content in article/div/p but only the date after the <br> tag. How is that done?

<article>
    <h2>Man rescued after falling into Crater Lake</h2>
    <p class="summary highlight">
        Man rescued after falling 800 feet into Crater Lake in Oregon
    </p>

    <div class="body">
       <p>by Joe Sutton<br>
            June 11, 2019
        </p>
    </div>
</article>
$expression = "article/div/p";

Upvotes: 2

Views: 249

Answers (1)

kjhughes
kjhughes

Reputation: 111541

This XPath,

//br/following-sibling::text()

will select all following sibling text nodes after br.

Upvotes: 1

Related Questions