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
1
vote
1 answer

Getting the desired xml representation of an array from a plain object using nodejs

I am using nodejs and typescript. It is necessary to get such an xml file structure from the object, in which the number of nested Rub tags is arbitrary:
Dmitry
  • 93
  • 1
  • 6
1
vote
2 answers

xml2js not writing as expected

Given this XML layout: 1.10.0 And this code (based on this article): NewVersionNumber = '1.10.1'; fs.readFile("../config.xml", "utf-8", (err, data) =>…
user736893
1
vote
1 answer

ENOENT error on xml2js but file did exists

const xml2js = require('xml2js'); const fs = require('fs'); fs.readFile('https://www.tcmb.gov.tr/kurlar/today.xml', (err, data) => { if(err) console.log(err); var data = data.toString().replace("\ufeff", ""); …
Kaito
  • 80
  • 1
  • 10
1
vote
1 answer

How to parse input xml data to json in react with xml2js?

I am trying to parse the input xml data to json in react with the help of xml2js. import React, { useState } from "react"; import xml2js from "xml2js"; function Parser() { const [xmlData, setXmlData] = useState({}); let parser = new…
user14872626
1
vote
2 answers

JSON Length giving the incorrect value

I want to get the length of the JSON, but it's not giving the values i want. I am using XML to JSON converter library (xml2js). If do you know another library than xml2js. I can use it too. console.log(result.length) -> Returns the 2, which is…
Batur
  • 48
  • 1
  • 9
1
vote
0 answers

How do I convert a JS array property into an XML declaration with a namespace attribute using xml2js?

I'm using xml2js and trying to convert a Javascript object of this form: { RootElement: { id: "1234", name: "Foo", children: [ { id: "5678", name: "Bar", props: [ { name: "Baz", …
Scott Sauyet
  • 49,207
  • 4
  • 49
  • 103
1
vote
0 answers

How to remove an empty tag when converting JSON file to XML using xml2js?

I have the following code to convert a JSON file to XML, first the conversion from the XLS file to JSON is performed, then JSON to XML, the code works for basic structures of excel files, when I try to convert a file that contains more information…
1
vote
1 answer

How to read an xml file by browsing in React JS

I am trying to read XML file by browsing in local machine using input. Here is my code import React from "react"; import "./App.css"; import * as fs from "fs"; var parseString = require("xml2js").parseString; const fileToParse = …
Sayyam abbasi
  • 109
  • 1
  • 8
1
vote
1 answer

xml2js valueProcessor removing \t and \n

I have a problem with parsing an XML file. I want to remove strings with characters like \t\n. XML File: http://ftp.thinkimmo.com/home/immoanzeigen24/immo.xml { trim: true, normalize: true, attrValueProcessors: [cleanValue,…
Fabian Lurz
  • 103
  • 11
1
vote
0 answers

How can I achieve this object structure with xml2js?

I'm currently working with xml2js. I'm trying to parse a xml file with the following structure: 1 Gawen
m0ntem
  • 33
  • 4
1
vote
1 answer

npm xml2js - parseStringPromise - Why is this method async?

I am trying to understand if the method "parseStringPromise" and its counterpart "parseString" (which takes a callback) actually do I/O operations which require async. Does anyone know if the callback was just a convention that was followed and the…
1
vote
1 answer

XML2JS remove square brackets surrounding values

i'm using the xml2js node package to parse an xml feed. Is there any way to prevent the values being surrounded by square brackets? E.g. "reference": ["ABC123"] should be "reference": "ABC123" "items": [ { "reference": ["ABC123"], …
Scott
  • 1,280
  • 4
  • 20
  • 35
1
vote
1 answer

TypeScript: Select element of an array by type property

In a TypeScript project, I have an array of containers that carry a type property and some additional data, depending on their type. type Container = { type: Type; } type AContainer = Container<"a"> & { dataA:…
fefrei
  • 885
  • 1
  • 10
  • 27
1
vote
2 answers

Handle XML attributes when converting XML to JSON using Node.JS xml2js

I am trying to convert an XML file into JSON using xml2js on Node.JS. When I hit an attribute, it will give a '_' and '$' characters as replacement. I am fully aware that JSON does not have the concept of attributes that XML does. How do I convert…
thotheolh
  • 7,040
  • 7
  • 33
  • 49
1
vote
0 answers

How to iterate through complex JavaScript objects

I have an issue to iterate through a pretty complex response I got from an API. To describe the whole situation. I have an API which delivers XML. I am parsing XML to JavaScript objects using xml2js node module. Till some point it works fine,…
1 2
3
9 10