私は過去3日間この問題を抱えていました。私はXMLをHTTP経由でJSONに変換して、イオン2で表示できるようにしたいと思います。プロバイダのコードはここにあります。どんな助けもありがとう!ありがとう!それはこのxmlをJson ionic 2に解析する方法
'typings' is not recognized as an internal or external command,
operable program or batch file.
そして、最初の使用のようなエラーが発生した場合あなたは今、コマンド
typings install xml2json --save
を使用してxml2jsonためのタイピングをインストールすることができ、イオン2 にJSONにXMLを解析するための
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
import * as xml2js from "xml2js";
@Injectable()
export class News {
constructor(public http: Http) { }
public getData() {
this
.http
.get('https://www.ug.edu.gh/news.xml')
.map(res => {
var cleanedString = res.toString().replace("\ufeff", "");
xml2js
.parseString(cleanedString, (error, result) => {
console.log(result);
return result;
});
})
.subscribe((data) => {
console.log(data)
}, (err) => {
console.log(err)
});
}
}