[swift-users] XML parsing on Linux, with Swift 3.1

Georgios Moschovitis george.moschovitis at icloud.com
Tue Sep 5 01:23:50 CDT 2017


As an example, this SegFaults:

import Foundation

class ParserDelegate: NSObject, XMLParserDelegate {
    func parserDidStartDocument(_ parser: XMLParser) {
        print("Starting document")
    }

    func parser(_ parser: XMLParser, didStartElement elementName: String, namespaceURI: String?, qualifiedName qName: String?, attributes attributeDict: [String : String] = [:]) {
        print("*** \(elementName)")
    }
}

let xml = "<root><title name=\"test\">George</title></root>"
let data = xml.data(using: .utf8)!
let xmlParser = XMLParser(data: data)
xmlParser.delegate = ParserDelegate()
xmlParser.parse()

> On 5 Sep 2017, at 9:01 AM, Georgios Moschovitis <george.moschovitis at icloud.com> wrote:
> 
> 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.



More information about the swift-users mailing list