Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
run: |
PLATFORM_NAME="${{ matrix.platform.name }}"
if [[ "$PLATFORM_NAME" == "macOS" ]]; then
xcodebuild test -scheme ya-swift-html-xml-parser -destination "platform=macOS,arch=arm64"
xcodebuild test -scheme YaXHParser -destination "platform=macOS,arch=arm64"
else
GREP_PATTERN="${{ matrix.platform.grep }}"
UDID=$(xcrun simctl list devices available | grep -m 1 "$GREP_PATTERN" | awk 'match($0, /\(([-0-9A-F]+)\)/) { print substr($0, RSTART + 1, RLENGTH - 2) }')
Expand All @@ -58,7 +58,7 @@ jobs:

echo "Found available ${PLATFORM_NAME} simulator with UDID: ${UDID}"

xcodebuild test -scheme ya-swift-html-xml-parser -destination "platform=${PLATFORM_NAME} Simulator,id=${UDID}"
xcodebuild test -scheme YaXHParser -destination "platform=${PLATFORM_NAME} Simulator,id=${UDID}"
fi

test-linux-stable:
Expand Down
12 changes: 6 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import PackageDescription

let package = Package(
name: "ya-swift-html-xml-parser",
name: "YaXHParser",
platforms: [
.macOS(.v15),
.iOS(.v18),
Expand All @@ -15,16 +15,16 @@ let package = Package(
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "ya-swift-html-xml-parser",
targets: ["ya-swift-html-xml-parser"]
name: "YaXHParser",
targets: ["YaXHParser"]
)
],
dependencies: [],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "ya-swift-html-xml-parser",
name: "YaXHParser",
dependencies: ["CLibXML2", "LibXMLTrampolines"],
swiftSettings: [
.swiftLanguageMode(.v6),
Expand All @@ -48,9 +48,9 @@ let package = Package(
]
),
.testTarget(
name: "ya-swift-html-xml-parserTests",
name: "YaXHParserTests",
dependencies: [
"ya-swift-html-xml-parser"
"YaXHParser"
]
)
]
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ya-swift-html-xml-parser
# YaXHParser

A tiny, modern Swift wrapper for `libxml2` that makes XML & HTML parsing easy, taking a-dvantage of the latest Swift features.

Expand Down Expand Up @@ -29,7 +29,7 @@ A tiny, modern Swift wrapper for `libxml2` that makes XML & HTML parsing easy, t

## Installation

Add ya-swift-html-xml-parser as a dependency to your `Package.swift` file:
Add YaXHParser as a dependency to your `Package.swift` file:

```swift
dependencies: [
Expand All @@ -50,7 +50,7 @@ A common task in web scraping is to find all URLs for media, links, or embedded
This is especially useful for building scrapers for media sites (e.g., finding movie trailers or image galleries).

```swift
import ya_swift_html_xml_parser
import YaXHParser

let mediaHTML = """
<article>
Expand Down Expand Up @@ -86,7 +86,7 @@ do {
You can also perform basic queries and access element attributes and text content directly.

```swift
import ya_swift_html_xml_parser
import YaXHParser

let html = """
<html>
Expand Down Expand Up @@ -122,7 +122,7 @@ do {
Use `parseXML(string:)` for well-formed XML documents. By default, this function is **strict** and will throw an error if the XML is not perfectly well-formed. This is ideal for validation and ensuring data integrity. For more advanced control, see the "Parsing Strategies" section below.

```swift
import ya_swift_html_xml_parser
import YaXHParser

let xml = """
<rss version="2.0">
Expand Down Expand Up @@ -210,7 +210,7 @@ The `ParsingService` actor provides a safe way to perform parsing operations fro
A common use case is to offload parsing work from the main thread in a UI application to keep it responsive. The example below shows how to parse a batch of documents concurrently in a background task.

```swift
import ya_swift_html_xml_parser
import YaXHParser

let service = ParsingService()
let docsToParse = [
Expand Down Expand Up @@ -255,7 +255,7 @@ When using the `ParsingService`, keep the following in mind:
`StreamParser` processes large documents piece-by-piece to minimize memory usage. You provide a custom handler to react to parsing events as they occur.

```swift
import ya_swift_html_xml_parser
import YaXHParser

class MyEventHandler: StreamEventHandler {
var elementCount = 0
Expand All @@ -279,9 +279,9 @@ do {

## Comparison to SwiftSoup

**[SwiftSoup](https://github.com/scinfu/SwiftSoup)** is a popular, pure-Swift HTML parser. `ya-swift-html-xml-parser` has a different design philosophy and may be suitable for different tasks.
**[SwiftSoup](https://github.com/scinfu/SwiftSoup)** is a popular, pure-Swift HTML parser. `YaXHParser` has a different design philosophy and may be suitable for different tasks.

| Feature | ya-swift-html-xml-parser | SwiftSoup |
| Feature | YaXHParser | SwiftSoup |
|-----------------------|------------------------------------------------------|-------------------------------------------------------|
| **Core Engine** | A thin Swift wrapper around the system's `libxml2` C library. | A feature-rich, pure Swift implementation. |
| **Dependencies** | None (Foundation-free). | None (Pure Swift). |
Expand All @@ -290,7 +290,7 @@ do {
| **Concurrency** | Provides an actor for uncommon thread-safe parsing needs. | Thread-safety is managed by the user. |
| **Ideal Use Case** | Fast data extraction and scraping where a minimal API is sufficient. | Projects that need to modify the DOM, or where a pure-Swift dependency is required. |

In short, choose **ya-swift-html-xml-parser** for a lightweight tool focused on fast data extraction. Choose **[SwiftSoup](https://github.com/scinfu/SwiftSoup)** when you need a comprehensive, pure-Swift toolkit for more complex DOM manipulation.
In short, choose **YaXHParser** for a lightweight tool focused on fast data extraction. Choose **[SwiftSoup](https://github.com/scinfu/SwiftSoup)** when you need a comprehensive, pure-Swift toolkit for more complex DOM manipulation.

## Local Development

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Testing

@testable import ya_swift_html_xml_parser
@testable import YaXHParser

#if canImport(Darwin)
import Darwin.C
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Testing

@testable import ya_swift_html_xml_parser
@testable import YaXHParser

@Suite("Concurrency Tests")
struct ConcurrencyTests {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Testing

@testable import ya_swift_html_xml_parser
@testable import YaXHParser

@Suite("Real-World HTML Parsing")
struct HTMLParsingTests {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Testing

@testable import ya_swift_html_xml_parser
@testable import YaXHParser

@Suite("Querying (XPath & CSS)")
struct QueryTests {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Testing

@testable import ya_swift_html_xml_parser
@testable import YaXHParser

#if canImport(Darwin)
import Darwin.C
Expand Down