我从 Flutter 中的 URL 检索 XML 数据并用于xml2json
转换数据,但我似乎无法将其分离。
我从 XML 中得到以下数据结构:
flutter: {
NowPlaying: {
Group: {$t: ALL},
CutID: {$t: 14406},
Length: {$t: 210.40},
Title: {$t: WISHING WELL},
Outcue: {},
Agency: {},
Userdef: {},
Billboard: {},
Artist: {$t: TERENCE TRENT D'ARBY},
Album: {},
Producer: {},
AlbumID: {},
SongID: {}
}
}
如何将此信息分解为变量或数据集并分别打印结果,主要Title
是Artist
和Length
?
class Connect {
Future fetchData() async {
final response = await http.get(Uri.parse('https://url/livenow.xml'));
if (response.statusCode == 200) {
xml2json.parse(response.body);
var jsondata = xml2json.toGData();
var data = json.decode(jsondata);
print(data);
}
}
}