Merged
Conversation
0095517 to
0d3bd0c
Compare
Element now has find(), findall(), iterfind(), findtext() — the core ElementTree query API. Path syntax (tag, .//tag, *, .., [@attrib], [tag='text']) is translated to XPath and evaluated by the SIMD engine. Also adds: - extend(), makeelement() on Element (raise TypeError) - iter() now includes self (matching stdlib behavior) - itertext() now yields text/tail in correct stdlib order - ET module: fromstringlist, tostringlist, dump, iselement - ET module: SubElement, Comment, PI, indent (raise TypeError) - ET module: register_namespace (no-op), ElementTree.write (TypeError) - ET module: ElementTree.iter, findtext, iterfind 131 new tests (322 total): - 49 ET compat tests (parse, ElementTree class, find/findall, read-only) - 82 exhaustive drop-in tests cross-validating every operation against stdlib xml.etree.ElementTree on 7 corpus types - Property tests (Hypothesis) for iter, itertext, find, len, text/tail - Adversarial: empty docs, deep nesting, entities, mixed content, CDATA Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Full read-only drop-in compatibility with
xml.etree.ElementTree.Element methods added
find(path),findall(path),iterfind(path),findtext(path, default)— ET path syntax translated to XPathextend(),makeelement()— raise TypeError (read-only)Element fixes
iter()now yields self first (matching stdlib)itertext()now interleaves text/tail in correct stdlib orderET module functions added
fromstringlist(),tostringlist(),dump(),iselement()SubElement(),Comment(),ProcessingInstruction()/PI(),indent()— raise TypeErrorregister_namespace()— no-op for compatibilityElementTree.iter(),.findtext(),.iterfind(),.write()(raises)Test coverage
What's NOT supported (by design)
TreeBuilder,XMLParser,XMLPullParser— incremental parsingcanonicalize— C14N serialization🤖 Generated with Claude Code