FastXML 1.2.0

FastXML 1.2.0

Morgan Fitussi 维护。



FastXML 1.2.0

  • Morgan Fitussi

FastXML

一个快速的、适合 Swift 的、经过测试的 XML 解析器,使用 Swift 编写

GitHub license Carthage compatible Cocoapods compatible Build Status Platform

用法

示例 XML

<breakfast_menu>
	<food>
		<name language="english">Belgian Waffles</name>
		<price currency="dollar">5.95</price>
		<description>Two of our famous Belgian Waffles with plenty of real maple syrup</description>
		<calories>650</calories>
	</food>
	<food>
		<name language="french">Toast français</name>
		<price currency="euro">3.50</price>
		<description>Tranches épaisses faites à partir de notre pain au levain fait maison</description>
		<calories>600</calories>
	</food>
</breakfast_menu>

给定的

FastXML(xmldata: xmlString.data(using: .utf8)!) { (xml, error) in
	print(xml!["breakfast_menu"]["food"][0]["name"].value)
	print(xml!["breakfast_menu"]["food"][0]["name"]["$language"].value)
	print(xml!["breakfast_menu"].tags)
	print(xml!["breakfast_menu"]["food"][0].tags)
	print(xml!["breakfast_menu"]["food"][0]["name"].attributes)
}

输出

"Belgian Waffles"
"english"
["food"]
["name","price","description","calories"]
["language"]

要求

  • Swift 4.0+ | iOS 8.0+ | macOS 10.10+ | tvOS 9.0+ | watchOS 2.0+
  • Xcode 8 或更高版本

安装

CocoaPods

您可以使用 CocoaPodsFastXML 添加到 Podfile 来安装它。

platform :ios, '8.0'
use_frameworks!

target 'MyApp' do
    pod 'FastXML', '~> 1.2.0'
end

Carthage

创建一个 Cartfile 列出框架并运行 carthage update。按照 说明$(SRCROOT)/Carthage/Build/iOS/FastXML.framework 添加到 iOS 项目中。

github "Dohko/FastXML" ~> 1.2.0

手动安装

下载并将 FastXML.swiftTag.swift 拖放到您的项目中。

Swift 包管理器

您可以使用 Swift 包管理器 通过将适当的描述添加到 Package.swift 文件来安装 FastXML

import PackageDescription

let package = Package(
    name: "PROJECT_NAME",
    targets: [],
    dependencies: [
        .Package(url: "https://github.com/dohko/FastXML.git", majorVersion: 1, minor: 2)
    ]
)

许可证

FastXML 采用 MIT 许可证发布

支持

作者

Morgan Fitussi,[email protected]