Existing swift package with API to stream XML?

Does anyone know of an existing swift package for writing XML using a stream based API?

For example an API where I can call methods like startDocument, startElement, writeAttribute, endElement... as opposed to building up a DOM structure that is then serialized.

Here's an objective-c version of what I'm looking for:

Curious if there is a similar swift package around?

Thanks,
Jesse

Why does it have to be written in Swift? Why can't you just use the objective c library above in your swift project?

Thanks for response, I may. I was just checking to see if there was already a swift version out there that I couldn't find.

Generally I prefer swift version of things because:

  1. API is likely designed to look nicer in swift
  2. I'm building package and easiest to just include another Package based source.
  3. There can be bridge performance issues (I don't know if this is really true anymore) but I've seen in past. For example I "think" my swift strings are in UTF8, going to Objective-c I think means they all need to be copied/encoded into UTF16. Probably not a big deal, maybe some magic avoids this, but I never really know what the bridge is doing.

See here for a list of swift libraries that include APIs for streaming XML.

1 Like

Thanks for your help. I now realize I've been doing pretty dumb google searches when looking for swift libs... I see much better results just searching github with language:Swift. Thanks, that will help me out in the future.

i wonder what is your task at hand to write XML to a stream this "SAX" way. i remember forming XML manually, but that was to a string (not stream) and quite straightforward

s += "<" + name
...
s += "</" + name + ">"

You should also consider removing the keyword "stream" from the query to broaden your search. The results may still include libraries that stream but don't mention it in the documentation.

See also Searching for repositories - GitHub Docs.

1 Like
Terms of Service

Privacy Policy

Cookie Policy