Skip to content

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

Description

@mathieu17g

v0.4 preserves inter-element whitespace as Text nodes (XML 1.0 §2.10 conformance: a processor must pass all non-markup characters through). A consequence is that children(node) on pretty-printed documents interleaves whitespace Text nodes with elements, and dependents that iterate or index children expecting elements need a nodetype filter. Three v0.4 migrations already hit exactly this pattern:

Proposal: add an explicit element-only accessor pair, mirroring EzXML's eachelement/elements:

  • eachelement(node) — lazy iterator over the child elements of a Node/LazyNode (skipping Text, Comment, ProcessingInstruction, …), built on children/eachchildnode;
  • elements(node) — the collected Vector counterpart.

Non-breaking v0.4.x addition. It gives dependents the pre-0.4 "children are elements" convenience back as an explicit, conformant idiom — for el in eachelement(node) — instead of an implicit assumption about whitespace handling. Happy to open the PR if there's agreement on the names.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions