Skip to content

Parsing RSS in an event-driven fashion #177

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

You must be logged in to vote

You assumptions are good, and the code would give you the <item> event of the input, but nothing else. To make it work, you would need to manually iterate over the events, detect the start <item>, then start to build XmlNode until you reach the next </item>. Since you need to remember state during the iteration, this unfortunately doesn't work that well with the built-in iterator methods such as where, but you can get this to work something along the lines of:

var started = false;
for (final event in parseEvents(input)) {
   if (event is XmlStartElementEvent && event.name == 'item') {
      started = true;
   } else if (event is XmlEndElementEvent && event.name == 'item') {
      started = 

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