Xmlprocessor - An android asynchronous xml processor based on XmlPullParser, targeting RSS.

Related tags

App xmlprocessor
Overview

Description

An android asynchronous xml processor based on XmlPullParser, targeting RSS.

Versions

Getting Started (V1.0.0)

Add the dependency in build.gradle (App module)

compile 'com.eukaprotech.xmlprocessor:xmlprocessor:1.0.0@aar'

Usage (V1.0.0)

To process an xml string already loaded from a file or an RSS feed. The xml string will be processed into a JSONObject list, HashMap list or JSONArray.

A sample xml_string response from an RSS feed.

        <rss version="2.0">
            <channel>
            <title>Music Industry</title>
            <link>https://www.einnews.com/news/newsfeed_music</link>
            <description/>
            <generator>EIN News</generator>
            <item>
                <title>
                'The status quo will be obliterated!' – the inventors making their own musical instruments
                </title>
                <link>
                https://www.einnews.com/article/417438078/V3TJlquqo0Ojg5t7?ref=rss&ecode=3wHjNW-Lw4Tcr_9P
                </link>
                <guid isPermaLink="false">https://www.einnews.com/article/417438078</guid>
                <pubDate>Fri, 24 Nov 2017 08:04:13 GMT</pubDate>
                <description>
                &#8230; kept. If someone turned their <span class="match">music</span> up too loud, you imagine &#8230; have travelled there, too. The <span class="match">music</span> keeps changing location with &#8230; ‘It will change the way <span class="match">music</span> functions’ … Subhraag Singh with &#8230; won this year’s Guthman <span class="match">musical</span> instrument competition at Georgia &#8230;
                </description>
            </item>
            <item>
                <title>Do You Have News to Share? Get It Published.</title>
                <link>
                https://www.einnews.com/article/417465808/SVgKa5jGvEeh4_1Z?ref=rss&ecode=3wHjNW-Lw4Tcr_9P
                </link>
                <guid isPermaLink="false">
                https://www.einnews.com/article/417465808/SVgKa5jGvEeh4_1Z
                </guid>
                <pubDate>Fri, 24 Nov 2017 12:09:36 GMT</pubDate>
                <description>
                With EIN Presswire press release distribution services you will reach decision makers and journalists plus get valuable SEO benefits.
                </description>
            </item>
            </channel>
         </rss>;

The required records have the tag "item". Each record has elements with the tags "title", "description", "link", "pubDate" and "guid".

Take "item" as the entryTag. Take "title", "description", "link", "pubDate" and "guid" as entryKeys.

Method 1.

          String entryTag = "item";
          ArrayList<String> entryKeys = new ArrayList<>();
          entryKeys.add("title");
          entryKeys.add("description");
          entryKeys.add("link");
          entryKeys.add("pubDate");
          RssXmlProcessor xmlProcessor = new RssXmlProcessor(entryTag, entryKeys);
          xmlProcessor.execute(xml_string, new RssXmlToHashMapListHandler() {
              @Override
              public void onStart() {

              }

              @Override
              public void onSuccess(List<HashMap<String, String>> items) {
                    //consuming the processed items using the same keys
                    for(HashMap<String, String> item: items) {
                          String title = item.get("title");
                          String description = item.get("description");
                          String link = item.get("link");
                          String pubDate = item.get("pubDate");
                    }
              }

              @Override
              public void onFail(Exception ex) {

              }

              @Override
              public void onComplete() {

              }
          });

Method 2.

          String entryTag = "item";
          ArrayList<String> entryKeys = new ArrayList<>();
          entryKeys.add("title");
          entryKeys.add("description");
          entryKeys.add("link");
          entryKeys.add("pubDate");
          RssXmlProcessor xmlProcessor = new RssXmlProcessor(entryTag, entryKeys);
          xmlProcessor.execute(xml_string, new RssXmlToJSONListHandler() {
              @Override
              public void onStart() {

              }

              @Override
              public void onSuccess(List<JSONObject> items) {
                    //consuming the processed items using the same keys
                    for(JSONObject item: items) {
                        try {
                            String title = item.getString("title");
                            String description = item.getString("description");
                            String link = item.getString("link");
                            String pubDate = item.getString("pubDate");
                        }catch (Exception ex){}
                     }
              }

              @Override
              public void onFail(Exception ex) {

              }

              @Override
              public void onComplete() {

              }
          });

Method 3.

          String entryTag = "item";
          ArrayList<String> entryKeys = new ArrayList<>();
          entryKeys.add("title");
          entryKeys.add("description");
          entryKeys.add("link");
          entryKeys.add("pubDate");
          RssXmlProcessor xmlProcessor = new RssXmlProcessor(entryTag, entryKeys);
          xmlProcessor.execute(xml_string, new RssXmlToJSONArrayHandler() {
              @Override
              public void onStart() {

              }

              @Override
              public void onSuccess(JSONArray items) {
                    //consuming the processed items using the same keys
                    for(int i=0; i<items.length(); i++) {
                        try {
                            JSONObject item = items.getJSONObject(i);
                            String title = item.getString("title");
                            String description = item.getString("description");
                            String link = item.getString("link");
                            String pubDate = item.getString("pubDate");
                        }catch (Exception ex){}
                     }
              }

              @Override
              public void onFail(Exception ex) {

              }

              @Override
              public void onComplete() {

              }
          });

Download

You might also like...
Show worldwide headline. API/Glide library/recycler view/volley library/kotlin/xml/ chrome custom tabs
Show worldwide headline. API/Glide library/recycler view/volley library/kotlin/xml/ chrome custom tabs

Show worldwide headline. API/Glide library/recycler view/volley library/kotlin/xml/ chrome custom tabs. - you can click on headline and it will open an article of that news in the app(no need to go to chrome or any browser)

FDPClient-EDITED - A free mixin-based injection hacked-client for Minecraft using Minecraft Forge based on LiquidBounce

FDPClient A free mixin-based injection hacked-client for Minecraft using Minecra

NewsApp is a an android project based on modern Android application tech-stacks and MVVM architecture.

NewsApp NewsApp is a an android project based on modern Android application tech-stacks and MVVM architecture. This project is for focusing especially

GitHub client for Android based on the abandoned official app
GitHub client for Android based on the abandoned official app

ForkHub ForkHub started off as a fork of the official Android app from GitHub, and has since seen lots of improvements. You can see a comprehensive li

DNS-based Host Blocker (and lightweight ad blocker) for Android

DNS-Based Host Blocking for Android This is a DNS-based host blocker for Android. In the default configuration, several widely-respected host files ar

Geoponics is an E-Commerce Android Based Application Designed for Farmers As Well As Normal Users to Buy and Sell Agricultural goods!
Geoponics is an E-Commerce Android Based Application Designed for Farmers As Well As Normal Users to Buy and Sell Agricultural goods!

Geoponics : E-Commerce Application Geoponics is an E-Commerce Android Based Aplication Designed for Farmers As Well As Normal Users to Buy and Sell Ag

Android Demo App for League of legends's Champions based on MVVM design pattern
Android Demo App for League of legends's Champions based on MVVM design pattern

🎉 LOL-Champs If this project is useful, please give it a star ⭐ A Android Sample App with champion information of the League of Legends(LOL) using An

🦄 Android Pokedex-AR using ARCore, Sceneform, Hilt, Coroutines, Flow, Jetpack (Room, ViewModel, LiveData) based on MVVM architecture.
🦄 Android Pokedex-AR using ARCore, Sceneform, Hilt, Coroutines, Flow, Jetpack (Room, ViewModel, LiveData) based on MVVM architecture.

🦄 Android Pokedex-AR using ARCore, Sceneform, Hilt, Coroutines, Flow, Jetpack (Room, ViewModel, LiveData) based on MVVM architecture.

A Frida based tool that traces usage of the JNI API in Android apps.
A Frida based tool that traces usage of the JNI API in Android apps.

jnitrace A Frida based tool to trace use of the JNI API in Android apps. Native libraries contained within Android Apps often make use of the JNI API

Owner
David
Software Developer
David
Android application to sync RSS without a server using DecSync

Flym DecSync Flym DecSync is a fork of Flym which adds synchronization using DecSync. To start synchronizing, all you have to do is synchronize your s

Aldo Gunsing 20 Dec 30, 2022
An Android RSS reader

BinoculaRSS This is an Android RSS reader application. Installation Install Android Studio, clone the project, and open the project. Follow any prompt

tminions 12 Oct 9, 2022
A Reeder copycat, in order to give Android an RSS reader similar to Reeder

A Reeder copycat, in order to give Android an RSS reader similar to Reeder, combines the interaction logic of Reeder with the design style of Material Design 3 (You).

Ashinch 1.5k Dec 31, 2022
Flym News Reader is a light Android feed reader (RSS/Atom)

BEWARE: The original developer stopped the development of the app so I'm starting to work on it to improve it and maintain it. Flym News Reader Light

null 0 Jul 26, 2022
Continuously archive RSS feeds to various different backends

RSStore Continuously archive RSS feeds to various different backends. Aka I try

//todo 0 Dec 18, 2021
Readow - Readow RSS Reader application. It’s fast and clean, giving you the freedom to enjoy your favorite news

Readow Readow RSS Reader application. It’s fast and clean, giving you the freedo

Pradeep Hr 7 Sep 20, 2022
Asynchronous Yandex.Predictor API wrapper for Kotlin/JVM.

Asynchronous Yandex.Predictor API wrapper for Kotlin/JVM.

Mikhail Titov 2 Jun 27, 2022
A performance-oriented fork of Purpur intended to increase performance for entity-heavy servers by implementing multi-threaded and asynchronous improvements.

Petal is a performance-oriented fork of Purpur intended to increase performance for entity-heavy servers by implementing multi-threaded and asynchronous improvements.

Bloom 224 Jan 3, 2023
An E-Commerce android App whose frontend is implemented using Kotlin & XML files and backend/database is implemented using My SQL & PHP files

An E-Commerce android App whose frontend is implemented using Kotlin & XML files and backend/database is implemented using My SQL & PHP files

null 4 Aug 25, 2022
CRUD Note taking app built for Android with Kotlin and XML.

Android Note Keeping App An offline android app that can be used to write notes on the fly to be retrieved later. Libraries Room Database. Lifecycle C

Moyosoreoluwa 3 Sep 19, 2022