I am using the Fetch API to call a webservice. The webservice does not return JSON - it returns XML.
What ability do we have in Wix Code to parse the XML String?
I am using the Fetch API to call a webservice. The webservice does not return JSON - it returns XML.
What ability do we have in Wix Code to parse the XML String?
Hi Jason,
unfortunately cool dudes does not use xml anymore, an old fellow like me can remember those days
at the moment wix code does not support npm modules (will be soon), but you can copy paste your favorite js util that does exactly that within your code on wix code (assuming it is an open source yeh?!)
there are lots and lots of things you may want to do with your data, the freedom to write your own code in your website backend lets you the power to address those challenges yourself using code
please let me know if that works,
Shlomi
The xml-js NPM library is now available in the Wix Package Manager:
See the Manipulate SVG example in this forum post .
Have fun everyone!
Hi, do you know why this does not work?
import xmljs from 'xml-js';
var convert = xmljs
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var result1 = convert.xml2json(xml, {compact: true, spaces: 4});
var result2 = convert.xml2json(xml, {compact: false, spaces: 4});
console.log(result1, '\n', result2);
@jessyerena What isn’t working? NPM libraries can only be used in backend code? Is this code in the backend?
Can’t get it to work in the backend.
Error: wixCodeNamespacesAndElementorySupport.min.js:1 Uncaught (in promise) Error: Unable to handle the request. Contact the site administrator or view site monitoring logs for more information.
The XML is an atom RSS feed (with CDATA sections)
fortunately I could also get a json feed (silly me for doing atom feeds).
I am wondering though, this article states that you can also call your backend function (return value: json) using an HTTP GET?
https://support.wix.com/en/article/velo-exposing-a-site-api-with-http-functions