Handling XML data with Alamofire in Swift

后端 未结 7 1995
一向
一向 2020-12-24 02:57

I started to use cocoapods with my current ios project. I need to use SOAP to get content with easy way for my ios project. I have googled it and Alamofire pod is great for

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-24 03:34

    tsaiid's answer in Swift 3 and Alamofire 4:

    Alamofire.request("http://my-web-service-domain.com", parameters: nil) //Alamofire defaults to GET requests
         .response { response in
            if let data = response.data {
              println(data) // if you want to check XML data in debug window.
              var xml = SWXMLHash.parse(data)
              println(xml["UserDTO"]["FilmID"].element?.text) // output the FilmID element.
            }
         }
    

提交回复
热议问题