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
2
votes
0 answers

Typescript, xml2js, explicitArray - how to deal with child nodes

I use xml2js to translate one type of XML into an object in Typescript. With its explicitArray option, xml2js forces users to either always generate arrays for nodes (explicitArray=true), or make array generation depending on the number of elements…
2
votes
0 answers

Can xml2js generate multiple text nodes under one parent?

I'm trying to generate XML containing structures similar to the following:

Some text ... Bold text ... some more text ... Italic text ... and yet more text.

What input to new…
Ben Whitmore
  • 857
  • 1
  • 6
  • 15
2
votes
0 answers

xml2js + Nuxt, how to use it?

I'm using axios to get an XML file. That works fine. I'm receiving a string. Then, I wanto to convert it to JSON whit xml2js. But everything I've tried hasn't worked. Any thoughts on that?
Bruja
  • 368
  • 2
  • 10
2
votes
1 answer

parseString undefined in angular 6 using xml2js

I cannot get the xml2js code to work so far using angular 6. I have a service.ts returning xml however when calling xml2js.parseString to convert to json I consistently get an undefined error. "core.js:1673 ERROR TypeError: Cannot read property…
justTech
  • 25
  • 1
  • 5
2
votes
1 answer

How to map an xml response to typescript interfaces

I am trying to map an xml response (it uses text XMLHttpRequestResponseType) from a backend server to a typescript interface. Right now, I tried to use xml2js to map the xml into a JSON and then map the JSON to the typescript interface (I am working…
2
votes
1 answer

Node.js xml2js Parser Not Defined

All, I am trying to parse an HTTP response XML via xml2js and am running into an error. I am trying to follow these instructions: https://programmerblog.net/parse-xml-using-nodejs/ I do have the module installed and seems to be operating correctly.…
Andrew Petersen
  • 163
  • 1
  • 9
2
votes
2 answers

json to xml with xml2js Array elementname

I am using xml2js node to transform an json object to xml file. I want to set the array items element name when parsing my json { "myValue": "1", "myItems": [ "13", "14", "15", "16" ] } and i want it to look like…
joakimja
  • 2,707
  • 2
  • 17
  • 25
2
votes
2 answers

Issue with parsing using xml2js

I have an xml in which tag name contains colon(:) It looks something like this: data I am using following code to parse this xml to json but can't use it because the tag name contains colon. var xml2js =…
java_doctor_101
  • 3,287
  • 4
  • 46
  • 78
2
votes
1 answer

failing to get output from function

I'm trying to figure out how to get value from xml file and output that value to console. const path = require('path'); const fs = require('fs'); const parseString = require('xml2js').parseString; const sourceFile = path.join(__dirname,…
2
votes
1 answer

Use xml2js in browser

Is there an example of how to include xml2js in the browser page? Per xml2js https://github.com/Leonidas-from-XIV/node-xml2js/issues/215: "with the recent changes, xml2js should be working fine in the browser. A simple include does not seem to…
prototype
  • 7,249
  • 15
  • 60
  • 94
2
votes
1 answer

How to remove and update a XML tag in xml2js

How can I edit XML file by xml2js const fs = require('fs'); const xml2js = require('xml2js'); var fn = 'file.xml'; fs.readFile(fn, function(err, data) { parser.parseString(data, function(err, result) { //result.data[3].removeChild();…
Raya Nasiri
  • 151
  • 2
  • 14
1
vote
1 answer

Error in XML parsing with xml2js library when handling nested elements

I'm currently working on a Node.js script that involves parsing XML files using the xml2js library. The script reads an XML file, extracts specific elements, and builds a new XML output using xml2js.Builder(). The script works perfectly fine for…
I'll-Be-Back
  • 10,530
  • 37
  • 110
  • 213
1
vote
2 answers

xml2js building xml with one element being an array of objects

I am having an issue creating an array in XML where the array is one of elements rather than primatives. The expected XML is: ..... 05633310000
1
vote
1 answer

Selecting xml node by attribute id

My aim is simple, I just need to get the value by an attrbiute. For example consider this xml:
Alan A
  • 2,557
  • 6
  • 32
  • 54
1
vote
1 answer

remove additional braces after converting xml to json

I used the xml2js to convert the following xml string to json export async function parseXml(xmlString: string) { return await new Promise((resolve, reject) => parseString(xmlString, (err: any, jsonData: Book) => { if (err) { …
hulike2286
  • 61
  • 5
1
2
3
9 10