Documentation Language: Swift

Article

Implementation Notes

Notes about the lower-level wrappers that back the public API.

Underlying libxml2 Handles

The package stores libxml2 pointers directly inside the wrapper types:

These stored properties are intentionally kept as implementation details so the public API can stay small while still mapping closely to libxml2 behaviour.

Internal Iteration State

The iterator types for XMLElement, XMLAttribute, XMLNameSpace, and XMLTree keep internal cursor state that mirrors libxml2 sibling and child links. Their implementation is documented in source so that future maintenance can stay aligned with the traversal order relied on by the test suite.

Empty Sequences

emptyIterator() and emptySequence() are small helpers used throughout the package to avoid special-case collection code when libxml2 pointers are missing. They make properties such as children and attributes cheap to consume even when a node has no related values.

See Also

Essentials

A
Getting Started with SwiftLibXML

Add SwiftLibXML to a package and parse your first XML document.

A
Parsing and Traversal

Set up a document, read the root element, and walk the tree.

A
XPath Queries

Select matching elements with XPath expressions.

A
Working with Namespaces

Query namespace-prefixed elements and attributes using XPath.