asList

Returns the view of this ItemArrayLike collection as List

fun <T> ItemArrayLike<T>.asList(): List<T>(source)
import org.w3c.dom.Node
import org.w3c.dom.NodeList
import javax.xml.parsers.DocumentBuilderFactory

fun main() {
    val xml = """
        <books>
            <book>First</book>
            <book>Second</book>
        </books>
    """.trimIndent()

    val builder = DocumentBuilderFactory.newInstance().newDocumentBuilder()
    val doc = builder.parse(xml.byteInputStream())
    val nodeList: NodeList = doc.getElementsByTagName("book")

    val books: List<Node> = nodeList.asList()

    books.forEach { println(it.textContent) }
}

Source