Skip to main content

JAXb Parser Exception:- Someone help me

1 reply [Last post]
GJ_P
Offline
Joined: 2013-02-13
Points: 0

I am getting error while parsing of below XML

<?xml version="1.0" encoding="UTF-8"?>


1

Custom MSG



2

Custom MSG


3

Custom MSG

Java Class

@XmlRootElement(name = "error")
public class Error {

private List ErrorDetail;
public List getErrorDetail() {
return ErrorDetail;
}
public void setErrorDetail(List errorDetail) {
ErrorDetail = errorDetail;
}
}

@XmlType(propOrder = {"errorcode", "msg" }, name = "errorDetail")
public class ErrorDetail {
private String errorcode;
private String msg;

public String getErrorcode() {
return errorcode;
}

public void setErrorcode(String errorcode) {
this.errorcode = errorcode;
}

public String getMsg() {
return msg;
}

public void setMsg(String msg) {
this.msg = msg;
}
}

Main Method

String fileName = "msg.xml";
Error error = new Error();
InputStream eh = Start.class.getResourceAsStream(fileName);
JAXBContext jaxbContext;
try {
jaxbContext = JAXBContext.newInstance(Error.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
error = (Error) unmarshaller.unmarshal(eh);
System.out.println(error);
} catch (JAXBException e) {
e.printStackTrace();
}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
tonya_rae_moore
Offline
Administrator
Joined: 2011-05-20
Points: 0

Moved to a more appropriate forum.

Tonya R. Moore
Assistant Community Manager