java - javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"TestSubject"). Expected elements are -
There are many help topics about this issue, but I have not found any solution that resolves my problem. I appreciate the guidance in solving this issue.
I tried to make XML through Marshal and generated from the code below XML.
I have to work with the XML structure below:
& lt ;? Xml version = "1.0" encoding = "UTF-8" standalone = "yes"? & Gt; & Lt; Test & gt; & Lt; TestSubject & gt; & Lt; First name & gt; Test1 & lt; / First name & gt; 'Enter code here' & lt; Lastname & gt; Last name & lt; / Last message & gt; & Lt; SSN & gt; 123456 & lt; / SSN & gt; & Lt; / TestSubject & gt; & Lt; / Test & gt; code
@ XmlRootElement (name = "test") public class test {public test} (testSubject = new ArrayList & lt; TestSubject & gt; ();} List & lt; test subject & gt; test topic; @xml element (name = "testSubject", type = testshow class.) Public list & gt; testSubject & gt; GetTestSubject () {return checkpoint;} public zero SetTestSubject (list & gt; test topic> test; topic) {this.testSubject = testSubject;} TestSubject class
public class TestSubject {String firstName ; Str Jingbettext.jpg = JAXBContext.newInstance (Test) .cq;); Unmarshaller unmarshaller = jc.createUnmarshaller (); File xml = new file ("c: //testSubjects.xml"); Test Test = (Test) unmarshaller.unmarshal (xml); ", local:" test topic "). Expected element & lt; {} Test & gt; Com.sun.xml.bind.v2.runtime.unmarshaller UnmarshallingContext.handleEvent at (UnmarshallingContext.java:662)
It seems that you The real XML is not showing which you are trying to be unbearable. The error you see will be when your XML form was in
< & lt; Test & gt; instead of pre> & lt; xml version = "1.0" encoding = "UTF-8" standalone = "yes"? ; & Lt; testSubject & gt; & lt; firstName & gt; test1 & lt; / firstName & gt; & lt; LastName & gt; lastname & lt; / last name & gt; & Lt; SSN & gt; 123456 & lt; / SSN & gt; & Lt; / TestSubject & gt; & Lt; / Test & gt; Just correct it.
As stacktrays are called
javax.xml.bind.UnmarshalException: unexpected element (Yuri: "", local: "test topic"). Expected element & lt; {} Test & gt; Your & lt; TestSubject & gt; The node is going where you & lt; Test & gt; are expecting the node as & lt; Test & gt; Having a root node means the same thing.
Comments
Post a Comment