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

xml2js is duplicating xml tags

I am trying to add a record to my XML file. Here is the original file 1 1 Here is…
J Seabolt
  • 2,576
  • 5
  • 25
  • 57
0
votes
1 answer

How to fix "xml2js" vulnerability in npm audit report for Microsoft Office add-in packages?

I am developing a Microsoft Office PowerPoint React add-in using various packages. I used Yeoman to start working with the example add-in. Later, I installed "antd" and "react-router-dom". However, upon running npm audit, I received a message…
0
votes
1 answer

How to automatically prepend namespace to tags when bulding XML from object?

Let's say I have this object: { myRoot: { $: { 'xmlns:abc': 'blahblah', } one: 'a', two: 'b', three: 'c' } } How can I have the builder build the tags with the abc: prefix so that I don't have to change the names of…
0
votes
0 answers

How to convert XML file into NodeJS array while keeping the same order as the original file?

I am trying to convert XML file into NodeJS object while keeping the same order as the original file. I have tried using the library xml2js, but it produces an object (not an array), and merges the tags with the same name. For example the following…
Nelibo
  • 13
  • 4
0
votes
1 answer

Using xml2js with attributes in XML

I am new to javascript and node and I would need to send some data into a DB. The data is coming from an xml file. I am trying to use xml2js package, building slowly from the example given, and adding attributes into the xml. Here is the code: var…
zukato
  • 1
  • 2
0
votes
0 answers

xml2js is not throwing an error when I pass in an invalid xml to parse.parseString

I am trying to write a jest test for the xml2js parse.parseString, but when I pass in an invalid xml it just bypasses the parse.parseString function rather than return the error in the callback function. I want to trigger the error in the callback…
H. Wynn
  • 403
  • 1
  • 4
  • 7
0
votes
1 answer

Getting an Array from a SOAP XML response in NodeJS

I'm working on a SOAP client in NodeJS. I've managed to consume using SOAPUi,the thing is that the response for the request I'm getting has an Array inside the body. The XML request looks like this:
BREAKWAVE
  • 63
  • 1
  • 4
0
votes
0 answers

Looking for a JSON2XML converter and back in Javascript (xml2js)

I try to convert an JSON Object into XML and back again in Javascript. The best so far I found is xml2js. But even this doesn't convert correct: A simple json like this: {name:"name1", list:["entry1","entry2"]} converts to xml like this:
mcfly soft
  • 11,289
  • 26
  • 98
  • 202
0
votes
3 answers

How to parse and append to XML file a new content?

I have an hardcoded XML file I need to parse and append some content. This is the file:
Tal Rofe
  • 457
  • 12
  • 46
0
votes
0 answers

How to convert xml2js response into proper JSON?

I am using the xml2js library to convert some xml to a JavaScript object but I get some weird characters as a response which I am not sure how to interact with. It does not look like normal JavaScript object and I need it to be in JSON which I can…
Angel Hadzhiev
  • 664
  • 2
  • 6
  • 20
0
votes
1 answer

xml2js usage to build up nodes dynamically based on queried data - need some data zero to many times

I'm using xmlbuilder to generate an xml file dynamically from data in a query. For the retailerTypeId custom-attribute node I need to loop through an array of retailerTypeIds and add a value node for each one in the array. Everything I do to inject…
0
votes
2 answers

Convert entities when parsing XML to JSON using xml2js?

I'm using a class to convert xml to json for my project like so: export class AccessionClass { constructor(accessionFilename) { this.accessionFilename = accessionFilename this.accessionXML =…
Marvin Budd
  • 431
  • 2
  • 2
0
votes
1 answer

xml2js parsed result without attributes

Using xml2js, what is the way to parse XML and return a result without the XML attributes? E.g., for the input bar I wish to get "foo": "Bar" Rather than "foo": { "_": "bar", "$": { "type": "attr" } }
Mr.
  • 9,429
  • 13
  • 58
  • 82
0
votes
1 answer

How to get XML from array of objects with xml2js?

I want to use xml2js to build XML file from array of objects. Is there a way to do it? This doen't work because xml2js.Builder() expects a single object. export const buildXML = (data: any[]) => { const builder = new xml2js.Builder(); return…
qweezz
  • 508
  • 4
  • 24
0
votes
2 answers

Implement javascript promise or async/await

I am on the newer side to programming; the concept of promises and async/await functionality is something I have had a hard time wrapping my head around. But I know that it is something I should be utilizing in this case. Background: Building a…
Hugobop
  • 125
  • 10