Skip to content

Can I parse RSS with this library? #176

Answered by renggli
erayerdin asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, that example works just fine:

import 'dart:convert';
import 'dart:io';

import 'package:xml/xml.dart';

Future<void> main(List<String> arguments) async {
  final url = Uri.parse('https://evrimagaci.org/rss.xml');
  final request = await HttpClient().getUrl(url);
  final response = await request.close();
  final input = await response.transform(utf8.decoder).join();
  final document = XmlDocument.parse(input);
  print(document.toXmlString(pretty: true));
}

The XML declaration is optional according to the standard, so this library doesn't require it. XmlDocument.parse is very strict with XML that does not follow the standard and throws an XmlParserException, i.e. when the tags are not …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@erayerdin
Comment options

Answer selected by erayerdin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants