1

I am trying to parse the below XML but getting the error. It is a standard XML returned by an apps web service

[Fatal Error] :2:51: The value of attribute "standardData" associated with an element type "null" must not contain the '<' character.

<Response success="true">
<Result><doesSandardDataExist standardData="{1=<node name="" required="N" hidden="N" 
entityName="standarddata">
  <node name="dataBasis" required="N" hidden="N" entityName="dataBasis" value=""/>
 </node>
, 2=<node name="" required="N" hidden="N" entityName="standarddata">
  <node name="dataBasis" required="N" hidden="N" entityName="dataBasis" value=""/>
 </node>
 }"
 doesSandardDataExist="true" reInvestmentData="">
 </doesSandardDataExist>
</Result>
<Messages></Messages>
</Response>

The below piece of code I used to parse the elements and the fatal error I am getting while parsing the document.

DocumentBuilder builder=DocumentBuilderFactory.newInstance().newDocumentBuilder();
InputSource scr = new InputSource();
scr.setCharacterStream(new StringReader(xml));
Document doc = builder.parse(scr);
Federico klez Culloca
  • 26,308
  • 17
  • 56
  • 95
Sourav Roy
  • 11
  • 1
  • 1
    The content of the `standardData` attribute is not valid. The service you're using is broken. – Federico klez Culloca May 06 '20 at 10:09
  • Do you mean the webservice needs to be corrected to return valid content in the attribute. or is there any other way to parse this format? The webservice is vendor provided app so if it needs correction, have to suggest specific format on that. – Sourav Roy May 06 '20 at 10:20
  • 1
    If you're absolutely sure that is the actual content returned by the service, than it is wrong (it's not valid xml) and should be fixed. Unless, that is, you want to parse the contents manually. In which case, good luck with that. – Federico klez Culloca May 06 '20 at 10:23
  • This so-called XML is so badly broken that there's absolutely no hope of parsing it. – Michael Kay May 06 '20 at 14:24

0 Answers0