scinfu / SwiftSoup

SwiftSoup: Pure Swift HTML Parser, with best of DOM, CSS, and jquery (Supports Linux, iOS, Mac, tvOS, watchOS)
https://scinfu.github.io/SwiftSoup/
MIT License
4.52k stars 345 forks source link

Have 3 <p> and need to display separately #244

Closed nandarosyadi closed 1 year ago

nandarosyadi commented 1 year ago

Hi guys, I've been research to split the part of html string. Here is the html code <p>Soal 1 dengan gambar</p>\n<p><img src=\"https://dian-media-staging-jakarta.s3.ap-southeast-3.amazonaws.com/media/WsywigImages/2023/05/24/015AC8AD-64E5-4E88-BE66-A4E8DE7D0CFA_Ijvbkm5.jpg\" alt=\"\" width=\"720\" height=\"900\"></p>\n<p>Ada soal lagi disini</p>

I've succed to split the image string, with this code let htmlDoc = try SwiftSoup.parse(htmlString) guard let imgSrc = try htmlDoc.select("img").first() else { return } let image: String = try imgSrc.attr("src") will return _https://dian-media-staging-jakarta.s3.ap-southeast-3.amazonaws.com/media/WsywigImages/2023/05/24/015AC8AD-64E5-4E88-BE66-A4E8DE7D0CFA_Ijvbkm5.jpg_

Now, I am trying to split the

part. Anyone can help for this? Thank you

nandarosyadi commented 1 year ago

I just read this issue, and it solve now