到目前为止,我无法使用 Angular 6 让 xml2js 代码正常工作。我有一个 service.ts 返回 xml,但是当调用 xml2js.parseString 转换为 json 时,我始终收到未定义的错误。
“core.js:1673错误TypeError:无法读取未定义的属性'parseString'”
服务.ts
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { map, filter, catchError, mergeMap } from 'rxjs/operators';
import { HttpHeaders } from '@angular/common/http';
export interface Zid {
zpid: number;
}
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/x-www-form-urlencoded',
}),
responseType: 'text' as 'text'
};
@Injectable({
providedIn: 'root'
})
export class CdataServiceService {
constructor(private …Run Code Online (Sandbox Code Playgroud)