Skip to content

Add eachelement/elements — element-only child iteration (#78)#80

Merged
mathieu17g merged 1 commit into
mainfrom
eachelement-v0.4.1
Jul 5, 2026
Merged

Add eachelement/elements — element-only child iteration (#78)#80
mathieu17g merged 1 commit into
mainfrom
eachelement-v0.4.1

Conversation

@mathieu17g

Copy link
Copy Markdown
Collaborator

Implements #78.

v0.4 preserves inter-element whitespace (XML 1.0 §2.10), so children(node) on pretty-printed documents interleaves whitespace Text nodes with elements. Two downstream migrations reimplemented the element-only loop by hand — PerezHz/NEOs.jl#219 and tecosaur/RestClient.jl#11 — so the idiom deserves a name:

  • eachelement(node) — lazy iterator over the child elements, skipping Text, Comment, CData, ProcessingInstruction, …
  • elements(node) — the collected Vector counterpart.

The generic definition is an Iterators.filter over children, working with both Node and LazyNode; a LazyNode specialization builds on eachchildnode instead, so no intermediate child Vector is materialized (measured: −55% allocations at equal speed on a 20k-children document). Tested on both readers in the whitespace testset.

Non-breaking addition, version bumped to 0.4.1: every dependent already on XML = "0.4" picks it up automatically on update.

v0.4 preserves inter-element whitespace, so children() on pretty-printed
documents interleaves whitespace Text nodes with elements; two
downstream migrations reimplemented the element-only loop by hand.
eachelement(node) is a lazy Iterators.filter over children — generic, so
it works with both Node and LazyNode — with a LazyNode specialization
built on eachchildnode so no intermediate child Vector is materialized
(-55% allocations at equal speed on a 20k-children document).
elements(node) is the collected counterpart. Tested on both readers in
the whitespace testset; version bumped to 0.4.1 (non-breaking addition).

Assisted-by: Claude (Anthropic)
@codecov-commenter

codecov-commenter commented Jul 5, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.47%. Comparing base (2e3e7ed) to head (78aed43).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main      #80   +/-   ##
=======================================
  Coverage   94.46%   94.47%           
=======================================
  Files           6        6           
  Lines        1790     1793    +3     
=======================================
+ Hits         1691     1694    +3     
  Misses         99       99           
Files with missing lines Coverage Δ
src/XML.jl 94.54% <100.00%> (+0.01%) ⬆️
src/lazynode.jl 92.02% <100.00%> (+0.02%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mathieu17g mathieu17g merged commit ace4398 into main Jul 5, 2026
8 checks passed
@mathieu17g mathieu17g deleted the eachelement-v0.4.1 branch July 5, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants