[swift-users] XML parsing on Linux, with Swift 3.1
Bouke Haarsma
bouke at haarsma.eu
Sat Sep 9 03:24:54 CDT 2017
On 2017-09-05 06:01:55 +0000, Georgios Moschovitis via swift-users said:
> Hi,
>
> I would like to parse an RSS feed using Swift 3.1 on Linux.
> I tried to use Foundations’s XML but I only managed to get segmentation faults.
> Is this supposed to work on Linux? I have only seen examples on iOS.
>
> Apart from that a quick search didn’t reveal any useful XML parsing
> library compatible with Linux.
>
> Any suggestions?
>
> -g.
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
XMLParser is a SAX-based parser, which is optimized for memory-usage.
There's also XMLDocument, which is DOM-based and is optimized for
developer convenience. If the XML files you're reading are small, i.e.
few megabytes, DOM-based is usually the easiest way to handle such
documents. XMLDocument is also implemented in Swift-Foundation, but I
found that it was lacking too much functionality (e.g. namespacing).
The situation might be different now -- you could check the source for
`NSUnimplemented()`.
Other options is to link libxml2 (C library), however that requires
much more effort on your end -- it doesn't expose high-level API's such
as XMLDocument.
--Bouke
More information about the swift-users
mailing list