Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yockow/swiftxhtml
XHTML parser/generator in Swift.
https://github.com/yockow/swiftxhtml
swift xhtml
Last synced: 24 days ago
JSON representation
XHTML parser/generator in Swift.
- Host: GitHub
- URL: https://github.com/yockow/swiftxhtml
- Owner: YOCKOW
- License: mit
- Created: 2019-04-05T08:51:27.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2022-09-27T06:57:55.000Z (about 2 years ago)
- Last Synced: 2023-03-02T05:27:01.708Z (over 1 year ago)
- Topics: swift, xhtml
- Language: Swift
- Homepage:
- Size: 281 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# What is `SwiftXHTML`?
`SwiftXHTML` will provide some functions related to XHTML.
It was originally written as a part of [SwiftCGIResponder](https://github.com/YOCKOW/SwiftCGIResponder),
and is intended to be used by it.# Requirements
- Swift 5.1
- macOS(>=10.15) or Linux## Dependencies
![Dependencies](./dependencies.svg)
# Usage
## As a parser
```Swift
import XHTMLlet string = """
Title
My Page
Welcome to my page.
"""
let document = try Parser.parse(string.data(using: .utf8)!)
print(document.prolog.xmlVersion) // -> "1.0"
print(document.element(for: "main")!.name) // -> "div"```
## As a generator
```Swift
import XHTMLlet page = Document.template(title: "Title",
contents:[.text("It's my page.")])
print(page.xhtmlString)/*
-- OUTPUT --TitleIt's my page.
*/
page.rootElement.body!.append(.comment("This is a comment."))
print(page.prettyXHTMLString)/*
-- OUTPUT --Title
It's my page.
*/
```## What are not supported yet...
- XPath
- CSS selector
- CSS parser# License
MIT License.
See "LICENSE.txt" for more information.