Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
100
rated 0 times [  105] [ 5]  / answers: 1 / hits: 20560  / 6 Years ago, thu, august 30, 2018, 12:00:00

I would like to parse xml data, retrieved from the server. Unfortunately HttpClient does not support xml, only json, therefore I installed the package xml2js:



npm install xml2js --save
npm install @types/xml2js --save-dev


Then I try to use it like this:



import {Parser} from 'xml2js';

Parser.parseString(xml_str, function (err, result) {
console.dir(result);
});


I get these two errors if I run it:



WARNING in ./node_modules/xml2js/node_modules/sax/lib/sax.js
Module not found: Error: Can't resolve 'stream' in 'C:projectsappnode_modulesxml2jsnode_modulessaxlib'

ERROR in ./node_modules/xml2js/lib/parser.js
Module not found: Error: Can't resolve 'timers' in 'C:projectsappnode_modulesxml2jslib'


I haven't found any solutions to this problem, maybe it is an Angular6 issue only. Is there any way, to parse xml in Angular6?


More From » xml

 Answers
61

You’ll have to install those dependencies. It’s unfortunately not well documented.



npm install --save stream timers

[#53595] Tuesday, August 28, 2018, 6 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
warren

Total Points: 679
Total Questions: 115
Total Answers: 78

Location: Antigua and Barbuda
Member since Sat, Apr 24, 2021
3 Years ago
;