0
votes

I'm trying to get the img url of a html file using XPath

For example :

My XPath Select

//div[contains(@class,'content')]/p//@src

The result is :

<div class="entry-content clearfix single-post-content" style="background-color: transparent;">
<p style="background-color: transparent;">
    <img src="https://example.com/0.jpg" alt="example" style="background-color: transparent;">
    <img src="https://example.com/1.jpg" alt="example">
    <img src="https://example.com/2.jpg" alt="example">
    <img src="https://example.com/3.jpg" alt="example">
    </p>

And i want to store the text so i use

string(//div[contains(@class,'content')]/p//@src)

But the result show me only

https://example.com/0.jpg

Is there any way i can get all the URL ?

1

1 Answers

0
votes

If you want your XPath to return list of strings, try

//div[contains(@class,'content')]//img/string(@src)