I am converting an XML to JSON using Javascript. The XML comes in as a string and I am not able to convert it into an XML object. Can anyone guide me in this regard.
As of now I have tried
var parser=new DOMParser();
xmlDoc=parser.parseFromString(xml,“text/xml”);
It throws an error indicating DOMParser is undefined. The above code is only for browsers, can you help in the execution of Apigee envt?
Dear @dj1 , Is your API publicly accessible ? Ideally if your backend API sets response content type to application/xml then out of the box XML to JSON should work for you. Can you post the XML you are trying to convert ?
you are right, DOMParser is not available in the Apigee env, basically there is no DOM here,
If you want to convert your XML to JSON, then i would strongly recommend you to use XMLToJson policy and then manipulate the json in your js policy
If you still need to parse XML - java is much easier option
If you still need to parse XML in js - you will have to rely on other js libs, maybe libxmljs or xmlbuilder and browserify it [i have not used them in apigee before], so you could include them in your js
I think by now you already know the solution but just for the sake of sharing knowledge I am posting this. I faced the same issue yesterday and this is how I resolved it:
<tns:ServiceErrorMessage xmlns:tns=“http://xmlns.oracle.com/adf/svc/errors/” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”>tns:codeAR:::AR_TW_INVALID_TRX_NUMBER</tns:code>tns:messageJBO-AR:::AR_TW_INVALID_TRX_NUMBER: AR-855040This transaction number already exists. Enter a unique transaction number.</tns:message>tns:severitySEVERITY_ERROR</tns:severity>tns:exceptionClassNameoracle.apps.fnd.applcore.messages.ApplcoreException</tns:exceptionClassName></tns:ServiceErrorMessage></env:Fault></env:Body></env:Envelope>
------=_Part_583_857466782.1661861839925–
You have added a new question, as a response! to a post from literally 7 years ago, and your question has no relation to the 7-year old question. Don’t do that.