How to Convert XML to JSON for Android?

November 28, 2016 0 Comments

Hello,

Xml data parse by 2 type : 1. SAX Parsing 2.DOM Parsing

But Development in android @ that time Not that use (if you know JSON PARSING)

Use XML to JSON data Convert

Step 1 : Gradle Import

allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" } // add this line
}
}

-----------------------------------------------------

dependencies {
compile 'com.github.smart-fun:XmlToJson:1.1.1' // add this line
}


Step 2: How to Used???

String xml = ...; // some xml String

XmlToJson xmlToJson = new XmlToJson.Builder(xml).build();

// convert to a JSONObject
JSONObject jsonObject = xmlToJson.toJson();

// OR convert to a Json String
String jsonString = xmlToJson.toString();

// OR convert to a formatted Json String (with indent & line breaks)
String formatted = xmlToJson.toFormattedString();

Get More Information : https://android-arsenal.com/details/1/4712

Contributer

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google

0 comments:

Hot-product

Best Watch Store

Popular Posts

Contact Form

Name

Email *

Message *