XML Parsing
val builder = DocumentBuilderFactory.newInstance().newDocumentBuilder()val inputStream = context.assets.open("sitemap.xml")// ^if the source is `String` use `byteInputStream`// EX: val inputStream = aStringData.byteInputStream()val document = builder.parse(inputStream)val elements = document.documentElement.getElementsByTagName("loc")// ^return a list of all tag matchedGet value in tag
Section titled “Get value in tag”Use .textContent to get the value in the tag
elements.item(0).textContent