Skip to content

Comments

Fix #128: Add Document.parseFragment() for XML fragment parsing#139

Open
gnodet wants to merge 1 commit intomainfrom
fix/128-fragment-parsing
Open

Fix #128: Add Document.parseFragment() for XML fragment parsing#139
gnodet wants to merge 1 commit intomainfrom
fix/128-fragment-parsing

Conversation

@gnodet
Copy link
Contributor

@gnodet gnodet commented Feb 21, 2026

Summary

  • Add Document.parseFragment(String) static method that parses XML fragments into a List<Node>
  • Supports fragments with multiple root-level elements, comments, processing instructions, and text nodes
  • Add 10 tests covering various fragment patterns including round-trip preservation

Test plan

  • Parse fragment with multiple elements
  • Parse fragment with comments, PIs, and trailing text
  • Round-trip preservation of fragment formatting
  • Null and empty input handling
  • Equivalence with Document.of(xml).nodes().toList()

Closes #128

Add a dedicated parseFragment(String) static method to Document that parses
XML fragments into a List<Node>. This supports fragments with multiple
root-level elements, comments, processing instructions, and text nodes.
Also add comprehensive tests covering various fragment patterns.
@github-actions
Copy link

✅ CI Build PASSED

Build Status: PASSED
Java Version: 21
Maven Command: ./mvnw verify

🎉 All tests passed! The build is ready for merge.

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.

Parsing a fragment supported?

1 participant