Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow parsing from an InputStream containing XML #52

Merged
merged 1 commit into from
Jun 7, 2018

Conversation

GarthSnyder
Copy link
Collaborator

This is kind of a weird backwater of the Apple API, but XMLParser can accept a Stream as input rather than a Data block. This is really nice in the case of FeedKit because it lets the download, the XML parsing, and the feed parsing all run concurrently. The time savings can be quite noticeable for large feeds. No other way of initializing an XMLParser gives this effect.

This patch adds a FeedParser(xmlStream:) initializer that propagates down to XMLFeedParser(xmlStream:), bypassing format-type detection.

Unfortunately, this isn't a complete solution on its own because you still need some way of getting a network data stream into the form of an InputStream, which as far as I can tell isn't a feature that's implemented in the Foundation API. I have some code that converts a URLSessionDataTask into a stream and I'd be happy to share it if you're interested, but it seems a bit peripheral to the core features of FeedKit.

@nmdias nmdias merged commit e0d0307 into nmdias:master Jun 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants