Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/onmyway133/reindeers
❄️ XML and HTML parser in Swift
https://github.com/onmyway133/reindeers
html swift xml
Last synced: 2 months ago
JSON representation
❄️ XML and HTML parser in Swift
- Host: GitHub
- URL: https://github.com/onmyway133/reindeers
- Owner: onmyway133
- License: other
- Created: 2016-10-08T21:47:12.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-08-15T19:41:36.000Z (over 4 years ago)
- Last Synced: 2024-05-02T05:59:35.740Z (9 months ago)
- Topics: html, swift, xml
- Language: Swift
- Homepage: https://onmyway133.github.io/
- Size: 441 KB
- Stars: 55
- Watchers: 8
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Reindeers
❤️ Support my app ❤️
- [Push Hero - pure Swift native macOS application to test push notifications](https://www.producthunt.com/posts/push-hero-2)
- [PastePal - Pasteboard, note and shortcut manager](https://www.producthunt.com/posts/pastepal)
- [Frame recorder - Recorder gif and video with frame](https://www.producthunt.com/posts/frame-recorder)
- [Alias - App and file shortcut manager](https://www.producthunt.com/posts/alias-shortcut-manager)
- [Other apps](https://onmyway133.github.io/projects/)❤️❤️😇😍🤘❤️❤️
[![Version](https://img.shields.io/cocoapods/v/Reindeers.svg?style=flat)](http://cocoadocs.org/docsets/Reindeers)
[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![License](https://img.shields.io/cocoapods/l/Reindeers.svg?style=flat)](http://cocoadocs.org/docsets/Reindeers)
[![Platform](https://img.shields.io/cocoapods/p/Reindeers.svg?style=flat)](http://cocoadocs.org/docsets/Reindeers)
![Swift](https://img.shields.io/badge/%20in-swift%204.0-orange.svg)![](Screenshots/Banner.png)
## Description
- Use libxml2
- Based on https://github.com/mattt/Ono
- Used in [Snowflake](https://github.com/onmyway133/Snowflake)## Usage
### XML, SVG, RSS
```xml
My first SVG
h1 {
color: blue;
font-family: verdana;
font-size: 300%;}
p {
color: red;
font-family: courier;
font-size: 160%;
}
This is a heading
This is a paragraph.
Visit W3Schools
```
```swift
let data = Utils.load(fileName: "test3", ext: "html")
let document = try? Document(data: data, kind: .html)let body = document.rootElement.child(index: 1)
body?.elements(XPath: "//p").first?.content
```### Query
- Get element info
```swift
let element = document.rootElement.child(index: 0)element.name
element.ns
element.line
element.attributes
element.parent
element.nextSibling
element.previousSibling
```- Get child elements
```swift
element.children { child, index in
return child.name == "a"
}element.children(name: "item")
element.children(indexes: [0, 2, 4])
```- XPath
```swift
let body = document.rootElement.firstChild(name: "body")
body?.elements(XPath: "//a").first?.attributes["href"]
body?.elements(XPath: "//div") { element in
return element.attributes["width"] == "100"
}
```- Turn Element to String
```
element.toAttributeString()
element.toXMLString()
```## Installation
**Reindeers** is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
pod 'Reindeers'
```**Reindeers** is also available through [Carthage](https://github.com/Carthage/Carthage).
To install just write into your Cartfile:```ruby
github "onmyway133/Reindeers"
```**Reindeers** can also be installed manually. Just download and drop `Sources` folders in your project.
## Author
Khoa Pham, [email protected]
## Contributing
We would love you to contribute to **Reindeers**, check the [CONTRIBUTING](https://github.com/onmyway133/Reindeers/blob/master/CONTRIBUTING.md) file for more info.
## License
**Reindeers** is available under the MIT license. See the [LICENSE](https://github.com/onmyway133/Reindeers/blob/master/LICENSE.md) file for more info.