I have an XML file from server. I use xmlPullPrser for parsing it into Kotlin, but it has an 'id' attribute . I don't Know how to get the 'id' value. thank you in advance for your answer. this is a part of my xml file :
```
<videoList >
<video id="843">
<title></title>
<author>Ghoneim</author>
</video>
<video id="887">
<title>Anatomic</title>
<author>Tewari</author>
</video>
</videoList>
```
this is some parts of my code for using XmlPullParser:
```
class VideoXmlParser {
@Throws(XmlPullParserException::class, IOException::class)
fun parse(inputStream: InputStream): List<Videos> {
inputStream.use { inputStream ->
val parser: XmlPullParser = Xml.newPullParser()
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false)
parser.setInput(inputStream, null)
parser.nextTag()
return readVideoList(parser)
}
}
}
@Throws(XmlPullParserException::class, IOException::class)
fun readVideoList(parser: XmlPullParser): List<Videos> {
val videos = mutableListOf<Videos>()
parser.require(XmlPullParser.START_TAG, ns, "videoList")
while (parser.next() != XmlPullParser.END_TAG) {
if (parser.eventType != XmlPullParser.START_TAG) {
continue
}
// Starts by looking for the video tag
if (parser.name == "video") {
videos.add(readVideo(parser))
} else {
skip(parser)
}
}
return videos
}
```
Once your
parseris at the 'video' tag you can useparser.getAttributeValue