Very easy to map xml value into an object!
- Map XML to Object
- Convert Object to XML String
- Stream XML from URL and map to object
public class CATALOG {
public CD[] CD;
}
public class CD {
public String TITLE;
public String ARTIST;
public String COUNTRY;
public String COMPANY;
public Float PRICE;
public Integer YEAR;
}
try {
CATALOG catalog = new XMLParser().fromXml(new URL("https://www.w3schools.com/xml/cd_catalog.xml"), CATALOG.class);
for (CD cd : catalog.CD) {
System.out.println(cd.TITLE);
System.out.println(cd.ARTIST);
System.out.println(cd.COMPANY);
System.out.println(cd.COUNTRY);
System.out.println(cd.YEAR);
System.out.println(cd.PRICE);
}
} catch (MalformedURLException e) {
e.printStackTrace();
}
Empire Burlesque
Bob Dylan
Columbia
USA
1985
10.9