Java : Simple XML Serialization(simple-xml-2.6.6.jar) gives error with XML file containing <SOAP-ENV:Body> & <SOAP-ENV:Envelope>

你说的曾经没有我的故事 提交于 2019-12-06 05:08:48

Now If I remove <SOAP-ENV:Envelope> & <SOAP-ENV:Body> from my XML it works fine. But when parsing XML with these tag I get the error.

And that is your problem right there. Simple XML attempts to parse the entire document that you give it. If you say:

serializer.read(Appointment.class, yourXML)

and the root of that XML is <SOAP-ENV:Envelope> followed by a <SOAP-ENV:Body> then it is not going to work. You need to make one or more classes to encapsulate the <SOAP-ENV:*> nodes in you XML. Otherwise Simple XML is going to get confused and tell you that it is not seeing what it expected to see. That is why it works when you remove those elements: because the XML now looks exactly like it expected it to be.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!