IONIC 4 (NOT beta) and it does NOT work for me (In IONIC 3 it is working) What have changed?’
I am trying to parse a XML file from my assets/xml/myfile.xml files…
Is there any other way to parse a XML?
First i thought it was a path problem but tested every path i can use. even moved the file to the root of Home (togheter with home.page.ts files).
My path see image:
I am using
XML2Js
@angular/common/http
I used it in Ionic 3 with no problems but i migrating to Ionic v4. And fix one problem after onther.
ERROR: 404 error…
My XML File is located in this folder Assets.
In Ionic 3 it works with the plugin
First of all I import my plugins in Home.page.ts
import { HttpClient } from '@angular/common/http';
import { HttpHeaders } from '@angular/common/http';
In my home.page.ts (For parsing)…
loadXML()
{
this.http.get('/assets/XML/myfile.xml',
{
headers: new HttpHeaders()
.set('Content-Type', 'text/xml')
.append('Access-Control-Allow-Methods', 'GET')
.append('Access-Control-Allow-Origin', '*')
.append('Access-Control-Allow-Headers', "Access-Control-Allow-Headers, Access-Control-Allow-Origin, Access-Control-Request-Method"),
responseType:'text'
})
.subscribe((data)=>
{
this.parseXML(data)
.then((data)=>
{
this.xmlItems = data;
});
});
}
If there is a better way to do this tell me also.
I find this a very easy to change update files.
If you answer my question Please write a long answer so i understan not a professional on this area, New at ionic 4.
Or send me a an example so i can test.
Best regards