I am trying to parse an xml string using jaxb. In fact , I need to extract the decimal value in literal .
That's the XML string :
<results>
<result>
<binding name="value">
<literal datatype="http://www.w3.org/2001/XMLSchema#decimal">369.0</literal>
</binding>
</result>
</results>
I have a java class Results :
package client;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class Results {
@XmlElement
String result;
@XmlElement
Double binding;
@XmlElement
Double literal;
public Double getLiteral()
{
return literal;
}
public Double geBinding()
{
return binding;
}
public String getResult()
{
return result;
}
}
When I tried to print the value , I'm getting null .So How can I get the decimal value between literal tag ?
Results re=(Results) JAXBContext.newInstance(Results.class)
.createUnmarshaller()
.unmarshal(new StringReader(my_xml));
System.out.println(re.getLiteral());