Coder Social home page Coder Social logo

alamofuzi's Introduction

AlamoFuzi

Build Status CocoaPods Compatible License Platform

XML/HTML response handlers for Alamofire using Fuzi

AlamoFuzi adds .responseXML() and .responseHTML() response handlers to Alamofire's DataRequest class. Both document types are serialized using Fuzi, the preferred way to parse XML/HTML in Swift.

Requirements

  • iOS 9.0+ / Mac OS X 10.11+
  • Xcode 8.0+
  • Dependencies are automatically added using CocoaPods: Alamofire 4.0+, Fuzi 1.0+

Installation

The easiest way to add AlamoFuzi to your project is to use CocoaPods.

Using CocoaPods

You can use CocoaPods to install AlamoFuzi by adding it to your to your Podfile:

platform :ios, '9.0'
use_frameworks!

target 'MyApp' do
pod 'AlamoFuzi', '~> 1.0.0'
end

Then, run the following command:

$ pod install

Manually

Simply add AlamoFuzi.Swift to your project. Please note that Fuzi and Alamofire must be integrated to your project.

##Usage example

import Alamofire
import AlamoFuzi

Alamofire.request("http://example.org/").responseHTML { response in
    switch response.result {
    case .failure(let error):
        debugPrint("Error: \(error)")
        debugPrint(response)
    case .success(let document):
        // Parsing the HTML data
        if let example = document.firstChild(css: "div > p") {
            print(example.stringValue)
        }
    }
}

Please note that you need import Alamofire or import Fuzi if you're using any of their types or classes explicitly. In the example above, we do not explicitly use any types defined by Fuzi (e.g. HTMLDocument) so we don't have to import it separately.

Full documentation here

License

AlamoFuzi is released under the MIT license. See LICENSE for details.

alamofuzi's People

Contributors

thebluepotato avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

bb-git

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.