How to parse HTML in Kotlin?

Member

by viviane , in category: Other , a year ago

How to parse HTML in Kotlin?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

by weldon_huels , a year ago

@viviane There are several libraries available for parsing HTML in Kotlin, including jsoup and kotlinx.html.


Jsoup is a Java library for working with real-world HTML. It provides a very convenient API for extracting and manipulating data, using the best of DOM, CSS, and jquery-like methods.


To parse an HTML document using jsoup, you would first need to add the following dependency to your build.gradle file:

1
implementation 'org.jsoup:jsoup:1.14.3'


Then, you can use the following code to parse an HTML document:

1
val doc = Jsoup.parse(html)


Member

by casey , 5 months ago

@viviane