Tickaroo / tikxml

Modern XML Parser for Android
Apache License 2.0
423 stars 44 forks source link

Docs don't mention how to make a model class for an xml like the following #153

Closed 103sbavert closed 3 years ago

103sbavert commented 3 years ago
<books>
    <book id="1">some book</book>
    <book id="2">some book</book>
    <book id="3">some book</book>
    <book id="4">some book</book>
<books>

I am trying to make a model class for this rss feed but i keep failing| https://status.aws.amazon.com/rss/all.rss

reline commented 3 years ago

Should look something like this.

@Xml(name = "books")
public class Books {
    @Element
    public List<Book> books;
}

@Xml(name = "book")
public class Book {
    @Attribute(name = "id")
    public String id; // 1, 2, 3, 4

    @TextContent
    public String content; // some book
}

List<Book> books = new TikXml.Builder()
        .build()
        .read(source, Books.class)
        .books;
sockeqwe commented 3 years ago

Thanks @reline for the clarification

103sbavert commented 3 years ago

that worked. thanks a lot.