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

Error when converting xml files to json files with help of xml2js

I have about 35000 xml files (7Gb total size) I need to convert to json files. I have written a conversion script with help of the npm package xml2js. It complains that I have not a callback function. Also it looks like there are some issues with…
Isak La Fleur
  • 4,428
  • 7
  • 34
  • 50
0
votes
3 answers

Unable to parse xml to json properly

I'm trying to parse a xml to json & i'm using xml2js in nodejs. Below is my code var chai = require('chai'); var chaiHttp = require('chai-http'); var request = chai.request; var should = chai.should(); var expect = chai.expect; var assert =…
0
votes
1 answer

Weird json data from xml2js

I'm trying to parse XML to JSON in Nodejs, but I'm getting back some very weird JSON data. This is the XML data:
Milan_w
  • 291
  • 2
  • 4
  • 17
0
votes
1 answer

Angular2 HTTP POST using observables subscribe shows data as 'undefined'

I'm POSTing data using Angular 2 to an URL which returns back XML response, I want to convert the data to JSON so I'm using xml2js. The conversion happens fine, but I get 'data' as undefined in 'subscribe' block. Please correct me if I'm wring, I'm…
Malick
  • 477
  • 4
  • 16
0
votes
1 answer

Nodejs - loop through JSON to find and replace the string

In NodeJS I want to find "This text must change" in json. This is currently my code: var fs = require('fs'), parseString = require('xml2js').parseString, xml2js = require('xml2js'); fs.readFile('content.xml', 'utf-8', function (err, data){ …
ZeroByte
  • 311
  • 1
  • 5
  • 11
0
votes
1 answer

Passing XML File To xml2js With Node.js

Background I have taken some sample data from a large XML response I will be working with in my app. I decided to save the xml to a response.xml file in my app so I can parse the data without making a bunch of unnecessary request to the api. I am…
wuno
  • 9,547
  • 19
  • 96
  • 180
0
votes
1 answer

XML Attribute not working in Node.js xml2js

I'm trying to parse XML with Node.js and xml2js. In the documentation is says that $ is the character to access attributes. It doesn't seem to be working in my case. The object result.ApiResponse.CommandResponse works fine. But anything I put…
Dany M
  • 113
  • 2
  • 2
  • 9
0
votes
1 answer

Xml not parsing string

I have following string "The quic\b\b\b\b\b\bk brown fo\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007x... [Beeeep]" But xmlBuilder and xml2js fails to parse this string due to these characters \b and \u0007. How can allow…
Farhan Yaseen
  • 2,507
  • 2
  • 22
  • 37
0
votes
1 answer

Node JS Xml2js xml parse

I am using xml2js provided by node. Right now I receive XML from mobile client for chat purpose and they can't control the flow of xml. So I receive xml like -
prateek3636
  • 155
  • 1
  • 7
0
votes
0 answers

Exempt one xml attribute to be converted into a string when JSON result is returned

I am using xml2js module of npm. It converts my xml to JSON. Suppose my xml is Akhil Sahni ISODate("2016-08-31T13:18:57.050Z") so it returns me a JSON object as { …
Akhil
  • 73
  • 1
  • 9
0
votes
4 answers

How to replace string in Javascript

I am trying to replace '

hi

' with 'hi' My JavaScript: var obj = {item:{title: params.title,description: params.text, link: req.headers['origin']+"/blog/blog-description/"+params.blog_id,…
MMR
  • 2,869
  • 13
  • 56
  • 110
-1
votes
1 answer

cannot access fields in JSON object (stringified), I am using Quasar / vue.js

I converted an excel spreadsheet to a JSON object using xml2js parseString() and then used JSON.stringify on the result. I have reviewed that data in the console and can see the data in a form that looks like I should be able to easily iterate…
Kuzma
  • 19
  • 3
-1
votes
2 answers

xml2js - Error: key $ must not start with '$'

I am using this javascript library xml2js to parse XML file to JSON format. This is the code: const fs = require('fs'); const xml2js = require('xml2js'); const util = require('util'); const parser = new xml2js.Parser(); fs.readFile('data.xml',…
Steve
  • 2,963
  • 15
  • 61
  • 133
-1
votes
1 answer

Got different answer from a return of a function

I'm blocked since few hours now, I wish somebody can help me figure out what I do wrong. This whole code is to get a json response from an API. I want to understand what are my errors, so please, explain a little ! ;) const fetch =…
BoBsmil3Y
  • 89
  • 1
  • 8
-1
votes
1 answer

Add comment to xml with nodejs

I am converting an object to an xml with nodejs. I want to add a comment to the xml. I tried this code but createComment is always undefined. const xml2js = require('xml2js'); const parser = new xml2js.Parser(); const…
yalpsideman
  • 23
  • 2
  • 6
1 2 3
9
10