I have the following XML:
<ns2:Person name="John" age="20" />
And I want to unmarshal it to JAXB object Person which was generated from the XSD.
this is the code I'm running:
JAXBContext context = JAXBContext.newInstance(PersoEntity.class);
Unmarshaller um = context.createUnmarshaller();
StringReader sr = new StringReader(xml);
Person p = (Person)um.unmarshal(sr);
Surprisingly I get the following exception:
javax.xml.bind.UnmarshalException
- with linked exception:
[org.xml.sax.SAXParseException: The prefix "ns2" for element "ns2:Person" is not bound.]
How do I solve it? Thanks