Java Jaxb: unexpected element (uri: ", local:" Create "). Expected elements: <{} Create>
I have a problem with my jaxb
<element name="create">
<complexType>
<sequence>
<element name="name" type="string"></element>
</sequence>
</complexType>
</element>
My xml:
<Create>
<name> coco </name>
</Create>
My java code:
JAXBContext context = JAXBContext.newInstance("MyPackage");
Unmarshaller decodeur = context.createUnmarshaller();
System.out.println("text : " + message);
msgObject = decodeur.unmarshal(sr);
if (msgObject instanceof Create)
{
System.out.println(" action");
}
And I have this:
unexpected element (uri: ", local:" Create "). Expected elements: <{ http://www.example.org/XSD_Maths } create>
And my code settled on this:
msgObject = decodeur.unmarshal(sr);
Is my xml good ?, can you help me because I donβt know what the problem is
Your XML schema may have a tag schemaas shown below.
<?xml version="1.0" encoding="UTF-8"?>
<schema
xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org/XSD_Maths"
xmlns:tns="http://www.example.org/XSD_Maths"
elementFormDefault="qualified">
a targetNamespace of http://www.example.org/XSD_Maths. XML :
<create xmlns="http://www.example.org/XSD_Maths">
<name> coco </name>
</create>
Unmarshalling DOM
DOM Document Element, , DOM, , . DocumentBuilderFactory.
documentBuilderFactory.setNamespaceAware(true);
, JAXB .