swxmlhash

how to use more efficiently SWXMLHash and how to set the class that will receive the data properly?

冷暖自知 提交于 2019-12-30 14:01:08
问题 I'm building a project for a train schedule app, and I'm using an API that returns an XML file,to manipulate the data i'm using the library called SWXMLHash. I need to extract the name of the departure station with its destinations and departure times. I created a class to store all these data, but I need to improve it because I'm having trouble extracting the destinations and departure times. I was able to loop over the xml file and get the names of the departure stations. Here is my class :

SWXMLHash parse Data object

亡梦爱人 提交于 2019-12-14 03:54:31
问题 I trying out with SWXMLHash and to mock a download from a website to parse, I created a file in the playground with the data. I got this as the response from URLSessionManager Data looks similar to: 3c3f786d 6c207665 7273696f 6e3d2731 ... But of course much longer. I read it in as follows: guard let fileURL = Bundle.main.url(forResource: "xmlData", withExtension: "") else { fatalError("cannot load file")} do { let xmlData = try Data(contentsOf: fileURL, options: .mappedIfSafe) } catch { print

How to deserialize NSDate with SWXMLHash

一世执手 提交于 2019-12-12 13:00:22
问题 I'm using SWXMLHash and have written an extension on NSDate for XMLElementDeserializable. I've followed how the basic types are extended at the end of this file. What I have looks like this: import Foundation import SWXMLHash struct BlogPost: XMLIndexerDeserializable { let date: NSDate static func deserialize(blogPost: XMLIndexer) throws -> BlogPost { return try BlogPost( date: blogPost["date"].value() ) } } extension NSDate: XMLElementDeserializable { /** Attempts to deserialize XML element

Implementing a custom Decoder in Swift 4

99封情书 提交于 2019-12-03 03:06:23
问题 I'd like to decode an XML document using the new Decodable protocol introduced in Swift 4, however, there doesn't seem to be an existing implementation for an XML decoder that conforms to the Decoder protocol. My plan was to use the SWXMLHash library to parse the XML, then possibly make the XMLIndexer class in that library extend the Decoder protocol so that my model can be initialized with an instance of XMLIndexer ( XMLIndexer is returned by SWXMLHash.parse(xmlString) ). My issue is that I

Implementing a custom Decoder in Swift 4

佐手、 提交于 2019-12-02 17:40:51
I'd like to decode an XML document using the new Decodable protocol introduced in Swift 4, however, there doesn't seem to be an existing implementation for an XML decoder that conforms to the Decoder protocol. My plan was to use the SWXMLHash library to parse the XML, then possibly make the XMLIndexer class in that library extend the Decoder protocol so that my model can be initialized with an instance of XMLIndexer ( XMLIndexer is returned by SWXMLHash.parse(xmlString) ). My issue is that I have no clue how to implement the Decoder protocol and I can't seem to find any resources online that

How to send a request with alamofire with xml Body

£可爱£侵袭症+ 提交于 2019-11-30 18:59:30
问题 I installed Alamofire in my project and now here is what I have done. I installed postman and I put my url and inside body a xml object and I got my result. Here is a picture of what I exactly have done with postman How can I now use Alamofire or SWXMLHash to send it as I send it with postman Thanks in advance! EDIT I tried this from another question: Alamofire.request(.POST, "https://something.com" , parameters: Dictionary(), encoding: .Custom({ (convertible, params) in let mutableRequest =