libxml2(except for macOS with Xcode 11.4 or later)
Usage
XML
Parsing & Introspection
import XML
let xml = #"""
<?xml version="1.0" encoding="UTF-8"?>
<!-- begin greeting -->
<greeting>Hello!</greeting>
<!-- end greeting -->
"""#
let document = try XML.Document(string: xml)!
document.root?.name // "greeting"
document.root?.content // "Hello!"
document.children.count // 3 (two comment nodes and one element node)
document.root?.children.count // 1 (one text node)
If you’re using Markup in an app,
link libxml2 to your target.
Open your Xcode project (.xcodeproj) or workspace (.xcworkspace) file,
select your top-level project entry in the Project Navigator,
and select the target using Markup listed under the Targets heading.
Navigate to the “Build Phases” tab,
expand “Link Binary With Libraries”,
and click the + button to add a library.
Enter “libxml2” to the search bar,
select “libxml2.tbd” from the filtered list,
and click the Add button.
Markup
A Swift package for working with HTML, XML, and other markup languages, based on libxml2.
This project is under active development and is not ready for production use.
Features
Requirements
Usage
XML
Parsing & Introspection
Searching and XPath Expression Evaluation
Modification
HTML
Parsing & Introspection
Searching and XPath Expression Evaluation
Creation and Modification
Builder Interface
Available in Swift 5.3+.
Installation
Swift Package Manager
If you’re on Linux or if you’re on macOS and using Xcode < 11.4, install the libxml2 system library:
Add the Markup package to your target dependencies in
Package.swift
:Add
Markup
as a dependency to your target(s):If you’re using Markup in an app, link
libxml2
to your target. Open your Xcode project (.xcodeproj
) or workspace (.xcworkspace
) file, select your top-level project entry in the Project Navigator, and select the target using Markup listed under the Targets heading. Navigate to the “Build Phases” tab, expand “Link Binary With Libraries”, and click the + button to add a library. Enter “libxml2” to the search bar, select “libxml2.tbd” from the filtered list, and click the Add button.License
MIT
Contact
Mattt (@mattt)