Skip to content

Conversation

@tomas-zijdemans
Copy link
Contributor

@tomas-zijdemans tomas-zijdemans commented Jan 7, 2026

New XML parsing and serialization module

What @std/xml has:

  • Streaming parser, DOM-style parser, serialization
  • Browser compatible, position tracking, spec-compliant

What @std/xml doesn't Have:

  • Namespace resolution, DTD/Schema validation, HTML entities
  • Custom entities, XPath/selectors, object-to-XML builder

My use case is a 600MB file of product data in a Google Shopping/Merchant Center XML format. I use Sax for this, as it can stream.

Benchmark Results

I picked Sax (for streaming) and fast-xml-parser (for non-streaming) as the reference cases. These seem like the most widely used packages, but please leave a comment if you would like to see a comparison to another package.

I ran these benchmarks a few hundred times (except the big streaming test that I ran about 15-20 times). All on a MacBook M1 Max. The test files are located in testdata (not the 600MB one naturally)

Small Files (<10KB)

Parser Time vs Baseline
Deno std xml 0.015ms baseline
SAX 0.027ms 1.8x slower
fast-xml-parser 0.042ms 2.8x slower

Large Files (large.xml - 300KB)

Parser Time vs Baseline
Deno std xml 3.03ms baseline
SAX 7.40ms 2.4x slower
fast-xml-parser 11.05ms 3.6x slower

Streaming (597MB file)

Parser Time Throughput vs Baseline
Deno std xml 11.59s 65.4K products/s baseline
SAX 17.04s 44.5K products/s 1.5x slower

@tomas-zijdemans tomas-zijdemans requested a review from kt3k as a code owner January 7, 2026 22:09
@crowlKats
Copy link
Member

could we get some benchmarks comparing to other parsers?

@tomas-zijdemans
Copy link
Contributor Author

could we get some benchmarks comparing to other parsers?

Yes, that's a good idea. I'll look into it.

@codecov
Copy link

codecov bot commented Jan 8, 2026

Codecov Report

❌ Patch coverage is 98.65526% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.49%. Comparing base (6b93b78) to head (9b1fe20).

Files with missing lines Patch % Lines
xml/_parse_sync.ts 96.08% 13 Missing ⚠️
xml/_tokenizer.ts 98.90% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6942      +/-   ##
==========================================
+ Coverage   94.28%   94.49%   +0.20%     
==========================================
  Files         584      593       +9     
  Lines       43186    44822    +1636     
  Branches     6933     7357     +424     
==========================================
+ Hits        40720    42353    +1633     
- Misses       2413     2417       +4     
+ Partials       53       52       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tomas-zijdemans
Copy link
Contributor Author

could we get some benchmarks comparing to other parsers?

Updated the description now. Let me know if you would like to benchmark against a specific package

@tomas-zijdemans tomas-zijdemans force-pushed the xml branch 6 times, most recently from 7f792e6 to e20f201 Compare January 8, 2026 21:04
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I have no idea why this formatting is happening 😅

@timreichen
Copy link
Contributor

Ref: denoland/deno#24995
There was no reply if DOMParser or something similar was to be implemented in deno, so I like this PR in general.
However, it might be worth to check with the deno core team what their current stance is on this before merging anything.

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.

3 participants