Hello,
I have issue with parsing XML using XMLParser when XML contains German specific characters, for example ü
This code:
import Foundation
let xml = "<Xml><Tag>Martin Hübner</Tag><Tag>Value</Tag></Xml>"
let data = xml.data(using: .utf8)!
let parser = XMLParser(data: data)
let parserDelegate = ParserDelegate()
parser.delegate = parserDelegate
parser.parse()
class ParserDelegate: NSObject, XMLParserDelegate {
func parser(_ parser: XMLParser, foundCharacters string: String) {
print("foundCharacters: \(string)")
}
}
has following output in Playground:
foundCharacters: Martin H
foundCharacters: übner
foundCharacters: Value
It looks to me like that XMLParser is not able to parse XML with German characters correctly, because with following XML:
let xml = "<Xml><Tag>Hello World</Tag><Tag>Value</Tag></Xml>"
output is correct:
foundCharacters: Hello World
foundCharacters: Value
Do you have any idea how to solve this issue?
Thank you
Selecting any option will automatically load the page