Error when parsing xml response javax.xml.bind.UnmarshalException -
Error when parsing xml response javax.xml.bind.UnmarshalException -
i'm not beingness able parse xml response.
my question, perfect xsd parse response correctly.
error:
javax.xml.bind.unmarshalexception: unexpected element (uri:"", local:"response"). expected elements <{http://equityapi.morningstar.com/}prices>, <{http://equityapi.morningstar.com/}data>,<{http://equityapi.morningstar.com/}p>, <{http://equityapi.morningstar.com/}response> my xml response:
<response xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"> <data idtype="ticker" id="fsrfx"> <prices> <p v="10.0" d="1986-09-29"/> <p v="88.63" d="2014-10-29"/> </prices> </data> a xsd generated response above in xml spy.
<?xml version="1.0" encoding="utf-8"?> <!-- w3c schema generated xmlspy v2015 sp1 (x64) (http://www.altova.com) --> <xs:schema attributeformdefault="unqualified" elementformdefault="qualified" targetnamespace="http://equityapi.morningstar.com/" xmlns:xs="http://www.w3.org/2001/xmlschema"> <xs:element name="p"> <xs:complextype> <xs:attribute name="v" use="required"> <xs:simpletype> <xs:restriction base="xs:decimal"> </xs:restriction> </xs:simpletype> </xs:attribute> <xs:attribute name="d" use="required"> <xs:simpletype> <xs:restriction base="xs:date"> </xs:restriction> </xs:simpletype> </xs:attribute> </xs:complextype> </xs:element> <xs:element name="data"> <xs:complextype> <xs:sequence> <xs:element ref="n1:prices" xmlns:n1="http://equityapi.morningstar.com/"/> </xs:sequence> <xs:attribute name="idtype" use="required"> <xs:simpletype> <xs:restriction base="xs:string"> </xs:restriction> </xs:simpletype> </xs:attribute> <xs:attribute name="id" use="required"> <xs:simpletype> <xs:restriction base="xs:string"> </xs:restriction> </xs:simpletype> </xs:attribute> </xs:complextype> </xs:element> <xs:element name="prices"> <xs:complextype> <xs:sequence> <xs:element ref="n1:p" maxoccurs="unbounded" xmlns:n1="http://equityapi.morningstar.com/"/> </xs:sequence> </xs:complextype> </xs:element> <xs:element name="response"> <xs:complextype> <xs:sequence> <xs:element ref="n1:data" xmlns:n1="http://equityapi.morningstar.com/"/> </xs:sequence> </xs:complextype> </xs:element> </xs:schema> thanks wanderson
your xml response not namespace qualified. if xml right need remove targetnamespace xml schematic reflect this.
xml parsing jaxb xsd
Comments
Post a Comment