<BADFM>
<Order >
<Ord OrdQty="1" faft="O">
<Bag pakka="1" DSE="C"/>
</Ord>
</Order>
</BADFM>
=================
@XmlRootElement(name="BADFM")
public class Message
{
@XmlElement(name="Order")
private MobBlock mob;
public MobBlock getMob() {
return mob;
}
public void setmob(MobBlock mob) {
this.mob = mob;
}
}
==================
public class MobBlock {
private Ord ord;
@XmlElement(name="Ord")
public Ord getOrd() {
return ord;
}
public void setOrd(Ord ord) {
this.ord = ord;
}
}
===================
public class Ord {
private Bagger Bagger;
@XmlElement(name="Bag")
public Bagger getBagger() {
return Bagger;
}
public void setBagger(Bagger Bagger) {
this.Bagger = Bagger;
}
}
=======================
public class Bagger {
private String dsc;
@XmlAttribute(name = "DSE")
public String getDSE() {
return dsc;
}
public void setDSE(String dsc) {
this.dsc = dsc;
}
}
========================
Its returning me null , when i tried to access
System.out.println(m.getMob().getOrd().getBagger().getDSE());
Could anybody please tell me what is the problem ?
This is my Parser class
public class BadFmParser
{
public static AbstractMessageT parse(String Str) throws Exception {
private static JAXBContext jc = null;
jc = JAXBContext.newInstance("mypackage");
Unmarshaller um = jc.createUnmarshaller();
BADFM badfmMessage = (BADFM) um.unmarshal(new StringReader(Str));
JAXBElement<? extends Message> element = badfmMessage.getMessage();
return element.getValue();
}
i am calling it this way
Message message = BADFMParser.parse(XMLFile);