Questions tagged [xml2js]

Simple XML to JavaScript object converter

Simple XML to JavaScript object converter. It supports bi-directional conversion. Uses sax-js and xmlbuilder-js.

More information on project page.

141 questions
0
votes
2 answers

JSON to XML conversion in Node JS service (using xml2js)

I need some help/advice with JSON to XML conversion in Node js. I have a service that gets a JSON object in request body that needs to convert to XML. I am able to achieve this using node-xml2js for json inputs with maximum one level of nested…
JavaNaresh
  • 5
  • 1
  • 1
  • 4
0
votes
1 answer

Add prefix to XML with lib xml2js

When going from XML to JS, the "processors.stripPrefix" allows you to remove the prefix. Is there any option to add prefix ? const jsonObj = { foo: { bar: { hello: 'world' } } }; const builder = new xml2js.Builder(); const xml =…
0
votes
1 answer

xml2js getting root node obj if name unknown (varies)

I am using xml2js to parse xml in my Aguilar CLI 9 project and wondering how to get the root node obj if the name is unknown (varies) on request. For example the following query syntax works to get the root node obj and attribute…
seanrco
  • 935
  • 5
  • 16
  • 32
0
votes
2 answers

Drilling through namespaces with xml2js

I have some xml that I have parsed using npms xml2js. It has a few namespaces in the xml and when I parse it and inspect the results I get this... Cool. I can go to steps deep by doing this console.log(result['bpr:release']['bpr:contents']) which…
SonOfNye
  • 75
  • 8
0
votes
0 answers

Nativescript Vue - function is blocking DOM

I've got a nativescript vue application, and on a certain page I need to fetch some data (every 3 seconds) from an api using axios. The data is returned in xml, and I convert it to json using xml2js. I'm using async/await for both these functions.…
greenerr
  • 119
  • 3
  • 10
0
votes
1 answer

Using Cloud Functions to store data form an external API on Firestore database

I have a Vue.js app running on Firebase and as a database I use Firestore. The app has to import data (clientes) form another app (app2), but app2 only exports by sending an XML code through POST to an address. To receive the POST from app2, my app…
0
votes
1 answer

ReferenceError: global is not defined in xml2js

I want to convert an XML String into JSON so as to fetch some user details. I am using xml2js library. Below is my typescript code: typescript.ts sendXML(){ console.log("Inside sendXML method") console.log(this.XMLAsString) …
Samarth Saxena
  • 175
  • 3
  • 18
0
votes
1 answer

Parsing an XML file with multiple tags using Node.js/Express/xml2js

my problem is as follows: I'm downloading an xml file using express.js and then parsing that file. Right now it looks something like this: US
Kevin Tran
  • 137
  • 1
  • 8
0
votes
1 answer

Node.js xml2js - When creating sitemap attributes are being ignored

I'm using node.js and xml2js to create a xml sitemap.xml. It looks all fine, but when I want to define the attributes e.g.: '$': { 'xmlns': 'http://www.sitemaps.org/schemas/sitemap/0.9' }, ... like this: var obj = { 'urlset': { …
Philipp M
  • 3,306
  • 5
  • 36
  • 90
0
votes
0 answers

JavaScript read XML

I am completely new to JavaScript and I am struggling with XML request validation not sure to proceed further. An XML file will get generated from application by clicking on the some button. The same content will be displayed in UI in one of the…
User0707
  • 3
  • 1
  • 2
0
votes
1 answer

How to correctly use JSON.parse()? JSON result is not valid

When I use JSON.parse(myJSONString) the result is not a valid JSON file. I'm in an nodejs environment. Any Ideas what I can fix in my code? I user XML2JS to converte an XML Api call to JS. I have printed out the results and already dived deeper…
user11911316
0
votes
1 answer

How to pass xml2js response to variable within node.js route?

I'm using xml2js with node.js to retrieve data from an API, but I would only like the code to run when the "/testpage" route is activated, which would then assign the api response to a variable and pass it along to a script on testpage.ejs where the…
Barrels
  • 13
  • 3
0
votes
0 answers

How to fetch data from an API correctly with xml2js

I am trying to use the JS fetch() coupled with the npm package xml2js to pull xml data from an API with react and display it with my frontend. I am able to do this with regular data but when it comes down to applying xml2js it is throwing back…
Reggie Snow
  • 142
  • 2
  • 13
0
votes
1 answer

How to escape "SOH" character in xml 1.0 using "xml2js" library?

Currently I am working on javascript code in order to request an external API of my network. The response of the API is in JSON format and my code convert it in XML format. The request and the conversion of data works well. Unfortunately when I want…
0xffxd
  • 3
  • 3
0
votes
1 answer

Get async result in async.filter() array nodejs

Need to parse some XML files from mass array with file_path values. Try to use async, fs, xml2js. When use single string file_path all works perfect. But when I use aync.filter() with array I can't understand how I can return result from…
Dan Mishin
  • 107
  • 2
  • 8