Answered step by step
Verified Expert Solution
Question
1 Approved Answer
How to unmarshall the xml data to a list of Map of Strings? I have an xml data like this , I have tried to
How to unmarshall the xml data to a list of Map of Strings?
I have an xml data like this ,
I have tried to unmarshall using this code ,
public class Book { private String author; private String title; private String genre; private float price; private float publish_date; private float description; }
public class mainClass { public static void main(String[] args) throws JAXBException, IOException { unmarshall(); } public static Book unmarshall() throws JAXBException, IOException { JAXBContext context = JAXBContext.newInstance(Book.class); return (Book) context.createUnmarshaller() .unmarshal(new FileReader("./books.xml")); } }
I am getting an exception like this ,
Exception in thread "main" javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"catalog"). Expected elements are (none). I knew its because of the "catalog" entity. But i want to do this for my project
please help. Thank you
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started