Swiftpack.co -  VeryLoveLoli/XMLValue as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
VeryLoveLoli/XMLValue
swift XML
.package(url: "https://github.com/VeryLoveLoli/XMLValue.git", from: "0.0.9")

XMLValue

一个Swift语言简易的XML取值

  1. Integration
  2. Usage

Integration

Xcode

File -> Swift Packages -> Add Package dependency

CocoaPods

GitHub XMLValue branch cocoapods

Usage

Initialization

import JSONValue
import XMLValue
        do {
            /// 获取html文件
            var htmlString = try String.init(contentsOf: URL.init(string: "http://www.baidu.com")!)
            
            /// 过滤XML非法字符
            htmlString = htmlString.xmlLegitimateString()
            
            /// html文档
            let html = HTMLDocument.init(htmlString)
            print(html.xmlString())
            
            /// html文档转XML数据
            let xmlData = html.xmlData()
            
            /// 解析XML数据 转化成 JSONValue
            let xmljson = try JSONXMLParser.xml(xmlData)
            /// JSON值 XML方式取值
            let xml = XMLValue.init(xmljson)
            /// 获取第一个 head 节点
            let head = xml.getOne("head")
            /// 输出 head 节点 第一个 子节点的属性
            head.elements[0].attributes.formatPrint()
            
        } catch  {
            /// 错误信息
            print(error)
        }

GitHub

link
Stars: 0
Last commit: 2 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

0.0.9
2 years ago

Swift XML Value

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API