I'm parsing XML using KissXML
. I can successfully parse small XML but have problem with large XML. Here's my code
let url = URL(fileURLWithPath: xmlPath!)
let xmlData = try! Data(contentsOf: url)
do {
let doc = try DDXMLDocument(data: xmlData, options:0)// This is not working if xml is large (6MB)
let project = try! doc.nodes(forXPath: "//Project") as! [DDXMLElement]
for user in project {
let ProjectName = user.attribute(forName: "ProjectName")!.stringValue
let userTime = user.attribute(forName: "UseTime")!.stringValue
print("ProjectName:\(ProjectName!),userTime:\(userTime!)")
}
}
catch {
print("\(error)") //Get some idea from this error
}
When parsing 12k XML was successful, but 6M XML was a failure. When parsing large XML(6M),doc equal to nil. I try to use NSXMLParser,the same problem arises,small file can work, big files can't.ERROR:NSXMLParserErrorDomain error 4.