honghaoz / Ji

Ji (戟) is an XML/HTML parser for Swift
MIT License
824 stars 64 forks source link

Ji: a Swift XML/HTML parser

Ji 戟

CI Status CocoaPods Version Carthage Compatible License Platform

Ji (戟) is a Swift wrapper on libxml2 for parsing XML/HTML.

Features

Requirements

Installation

CocoaPods

To integrate Ji into your Xcode project using CocoaPods, specify it in your Podfile:

use_frameworks!

pod 'Ji', '~> 5.0.0'

Then, run the following command:

$ pod install

Carthage

To integrate Ji into your Xcode project using Carthage, specify it in your Cartfile:

github "honghaoz/Ji" ~> 5.0.0

Swift Package Manager (SPM)

Prerequisites

brew install libxml2
brew link --force libxml2

Update Package.swift

To integrate Ji in your project, add the proper description to your Package.swift file:

// swift-tools-version:5.0
import PackageDescription

let package = Package(
    name: "YOUR_PROJECT_NAME",
    dependencies: [
        .package(url: "https://github.com/honghaoz/Ji.git", from: "5.0.0")
    ],
    targets: [
        .target(
            name: "YOUR_TARGET_NAME",
            dependencies: ["Ji"]
        ),
        ...
    ]
)

Manually

If you prefer not to use a dependency manager, you can integrate Ji into your project manually.

Usage

If you are using CocoaPods to integrate Ji. Import Ji first:

import Ji

let 戟文档 = 戟(htmlURL: URL(string: "https://cocoapods.org/pods/Ji")!) let attribution = 戟文档?.xPath("//ul[@class='attribution']")?.first print("作者(Author): (String(describing: attribution?.content))") // 作者(Author): Optional("ByHonghao Zhang")



## License

The MIT License (MIT)

Copyright (c) 2019 Honghao Zhang (张宏昊)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.