How would you Parse an XML in IONIC 4?

How would you Parse an XML in IONIC 4?

Or is it a better way to do it?

Assuming you are using the Angular version, look at any of the solutions ‘normal’ Angular developer use. I think there is a package called xml2json that you can install and use.

I using this:

node-xml2js

Ever had the urge to parse XML? And wanted to access the data in some sane,
easy way? Don’t want to compile a C parser, for whatever reason? Then xml2js is
what you’re looking for!

Description

Simple XML to JavaScript object converter. It supports bi-directional conversion.
Uses sax-js and
xmlbuilder-js.

Note: If you’re looking for a full DOM parser, you probably want
JSDom.

Installation

Simplest way to install xml2js is to use npm, just npm install xml2js which will download xml2js and all dependencies.

xml2js is also available via Bower, just bower install xml2js which will download xml2js and all dependencies.

Usage

No extensive tutorials required because you are a smart developer! The task of
parsing XML should be an easy one, so let’s make it so! Here’s some examples.

Shoot-and-forget usage

Is this Angular you mean?

But seems dont work with IONIC 4?

Check that it is compatible with Angular 7. What are the errors it throws?

1 Like

Error 404 I think I can not read file.

Get BlueMail for Android

See you this my case…

See this repo for an complete example:

1 Like

This works perfectly, but when i move it to my project i get:

Module not found: Error: Can’t resolve ‘timers’ in ‘/Users/kamalsalah/Documents/IONIC/IONIC_Startpacked/node_modules/xml2js/lib’

[ng] ERROR in ./node_modules/xml2js/lib/parser.js

[ng] Module not found: Error: Can’t resolve ‘timers’ in ‘/Users/kamalsalah/Documents/IONIC/IONIC_Startpacked/node_modules/xml2js/lib’

Confused…

I found the problem i had to install:

npm install --save stream timers

This i did not know!!