惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
T
Tor Project blog
U
Unit 42
G
Google Developers Blog
T
The Blog of Author Tim Ferriss
Recorded Future
Recorded Future
B
Blog
I
InfoQ
H
Help Net Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
aimingoo的专栏
aimingoo的专栏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
小众软件
小众软件
Spread Privacy
Spread Privacy
T
Tenable Blog
C
Cybersecurity and Infrastructure Security Agency CISA
F
Fortinet All Blogs
Microsoft Security Blog
Microsoft Security Blog
I
Intezer
P
Proofpoint News Feed
A
About on SuperTechFans
S
Securelist
D
DataBreaches.Net
Security Latest
Security Latest
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Threat Research - Cisco Blogs
Know Your Adversary
Know Your Adversary
大猫的无限游戏
大猫的无限游戏
Cyberwarzone
Cyberwarzone
AWS News Blog
AWS News Blog
Engineering at Meta
Engineering at Meta
MyScale Blog
MyScale Blog
V
Visual Studio Blog
A
Arctic Wolf
Hugging Face - Blog
Hugging Face - Blog
Project Zero
Project Zero
博客园 - 司徒正美
美团技术团队
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
B
Blog RSS Feed
Vercel News
Vercel News
T
Threatpost
博客园 - Franky
有赞技术团队
有赞技术团队
爱范儿
爱范儿
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
D
Darknet – Hacking Tools, Hacker News & Cyber Security
L
LINUX DO - 热门话题

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
I wrote my third XML parser. Here's why this one was different.
Paul · 2026-04-27 · via DEV Community

Hi, I'm Pasha, and I write XML parsers.

Not because the world needs another one. The world has xmlutil by Paul de Vrieze, which I will say specific nice things about further down. The world has JAXB. The world has, depending on how you count, several hundred XML libraries on Maven Central. Adding to the pile is not on anyone's wishlist.

And yet, here I am.

The first one I wrote years ago for a previous employer, behind a closed-source repo I no longer have access to. The second one, staks, is mine and works very well — if you write Kotlin and only Kotlin, and you are happy hand-rolling a small DSL per record. The third one is xml-fluss, which I just released, and the rest of this post is about why it exists.

So, let's get going.

The feed that started it

I have a soft spot for OPDS catalogs — Atom-flavored XML feeds for ebook libraries. They are exactly the kind of thing XML was invented for and exactly the kind of thing modern tooling makes you suffer to read.

Here is a fragment from an OPDS feed:

<feed xmlns="http://www.w3.org/2005/Atom"
      xmlns:opds="http://opds-spec.org/2010/catalog">
  <title>My Books</title>
  <updated>2026-04-26T10:00:00Z</updated>
  <entry>
    <id>urn:isbn:9780000000001</id>
    <title>The Master and Margarita</title>
    <author><name>Mikhail Bulgakov</name></author>
    <link rel="http://opds-spec.org/acquisition"
          type="application/epub+zip"
          href="/get/1.epub"/>
  </entry>
  <entry> ... </entry>
  <entry> ... </entry>
  <!-- 200,000 more entries -->
</feed>

Enter fullscreen mode Exit fullscreen mode

I want three things out of every <entry>: the <title>, the author's <name>, and the acquisition <link>'s href. I do not care about anything else. I am also aware that "200,000 more entries" is not a hypothetical — real catalogs ship feeds with hundreds of thousands of records. I am not going to load that into memory.

Why xmlutil wasn't quite the shape

Before I tell you what I did, a quick word on xmlutil. Paul de Vrieze has been working on it for years. It runs on the entire Kotlin Multiplatform target list (JVM, JS, Native, Android), plugs into kotlinx-serialization, handles QName-aware namespaces with prefix repair and Clark notation, encodes XML back out as well as decoding it, and supports mixed content, sealed-class polymorphism, and inheritance. If you need to encode XML, or your document matches a schema you fully control, that's the library to reach for. I mean it.

But.

The default deserialization path, XML.decodeFromString(...), builds the whole tree. Fine for config files, painful for a 2 GB feed.

There is a streaming escape hatch: decodeWrappedToSequence(reader). It is real and it works. I checked. The constraints: it expects a <container><Item/><Item/></container> shape, it is marked @OptIn(ExperimentalXmlUtilApi::class), and the part that mattered to me is that every field on every Item still has to be declared on a @Serializable data class, including the ones I do not care about, because that is how a binder works. Binders mirror.

What I wanted was a different shape of tool: find the records anywhere in this document, decode three fields per record, ignore the rest, never buffer the whole thing. That's a different model from a binder, and there's room for both.

Why staks wasn't the shape either

Quick aside on my own previous attempt. staks works, and I still use it for personal projects. Its DSL is designed for a Kotlin codebase with a Kotlin developer at the keyboard. The moment you put a Java consumer in the picture — say, a Spring Boot service in a polyglot codebase that wants the same parser — you discover that "tiny Kotlin DSL" is the worst surface area to expose to javac.

So when I started xml-fluss, I picked an architecture where the Kotlin user and the Java user could share the same runtime and the same annotation surface, and only the code-generator backend differs.

What xml-fluss looks like in five lines

Here is roughly what xmlutil would have me write:

@Serializable
@SerialName("entry")
data class Entry(
    @XmlElement val id: String,
    @XmlElement val title: String,
    @XmlElement val updated: String,
    @XmlElement val author: Author,
    @XmlElement val link: List<Link>,
    @XmlElement val summary: String? = null,
)
@Serializable data class Author(@XmlElement val name: String, ...)
@Serializable data class Link(@XmlAttribute val rel: String, @XmlAttribute val href: String, ...)

Enter fullscreen mode Exit fullscreen mode

Here is what I get to write with xml-fluss:

@XmlRecord("//atom:entry")
@XmlNs("atom", "http://www.w3.org/2005/Atom")
@XmlNs("opds", "http://opds-spec.org/2010/catalog")
data class Book(
    @XmlChild("atom:title")            val title: String,
    @XmlChild("atom:author/atom:name") val author: String,
    @XmlChild("atom:link/@href")       val download: String?,
)

Enter fullscreen mode Exit fullscreen mode

That is the entire description. No id, no updated, no summary, no nested Link class — because I do not need any of it. The KSP processor walks this data class at compile time and emits a BookParser object:

URI("https://example.org/opds/all").toURL().openStream().use { input ->
    BookParser.parse(input)
        .filter { it.download != null }
        .take(20)
        .collect { book -> println("${book.author} — ${book.title}") }
}

Enter fullscreen mode Exit fullscreen mode

The parser sits on top of Aalto, a fast pull parser. It never holds more than one Book in memory. The path matcher is a small NFA — a nondeterministic finite automaton, which is the same machinery regex engines use under the hood. The compiled path becomes a graph of states, and as the parser walks the document it keeps a stack of which states are currently active. When a START_ELEMENT arrives that satisfies the descendant axis and the namespace, you enter record mode; when the matching END_ELEMENT arrives, you emit. The descendant axis (//) keeps a state alive across deeper elements so that //book matches whether the <book> is two levels down or twelve.

Predicate filters evaluate at START_ELEMENT time using only the attributes present on the opening tag. That's the design, and it's what makes the streaming guarantee real. If the parser had to look ahead at the body of the element to decide whether to enter it, you would buffer.

A small mini-XPath, on purpose

I wanted just enough path syntax to express the things I actually do every week:

//entry                           // descendant axis
/library/section/author           // anchored
//entry[2]                        // positional
//book[@featured='true' and @lang='en']
{http://www.w3.org/2005/Atom}title
//link/@href                      // attribute leaf on a child

Enter fullscreen mode Exit fullscreen mode

Boolean logic is and / or with and precedence higher. Predicates use equality, inequality, and integer position. That's it. It is not XPath 3.1 and it is not trying to be — it is the minimum syntax that lets me select the records I want without writing a visitor. A more elaborate predicate engine would mean buffering, ambiguity around evaluation order, and a much bigger surface area to debug. I'd rather keep the engine small.

The Java side, where jspecify earns its keep

xml-fluss has a second module, xml-fluss-apt, that does the same thing for Java records via a plain javac annotation processor:

@NullMarked
package my.books;

@XmlRecord("//atom:entry")
@XmlNs(prefix = "atom", uri = "http://www.w3.org/2005/Atom")
public record Book(
    @XmlChild(path = "atom:title")            String title,
    @XmlChild(path = "atom:author/atom:name") String author,
    @XmlChild(path = "atom:link/@href")
    @Nullable                                 String download
) {}

// usage
try (Stream<Book> books = BookParser.parse(in)) {
    books.limit(20).forEach(b -> System.out.println(b.author() + " — " + b.title()));
}

Enter fullscreen mode Exit fullscreen mode

Two things are happening here that I am quietly proud of.

First: a single annotation surface (xmlfluss.*) on top of one shared runtime feeds two code generators (KSP for Kotlin, javac APT for Java records), so you get Flow<T> or Stream<T> depending on which side you write on.

Second: there is no separate nullable = true argument anywhere. On the Kotlin side this is free — the language already distinguishes String from String?, so the KSP processor just reads the type and that's the answer. Java doesn't have built-in null-safety, so the APT processor reads jspecify annotations instead. A record component sitting inside a @NullMarked scope without an explicit @Nullable is treated as required at parse time; the @Nullable ones can be absent without complaint. Same end result both languages, sourced from the type system that each one already has.

Why invent another nullable=true argument when both languages already give the answer?

What it deliberately does not do

A short list of things xml-fluss is not, so you can rule it out fast if you need them:

  • It does not encode XML, and it cannot. This isn't a missing feature, it's structural. The annotation surface is a query over an unknown document. How would you render @XmlRecord("//author//book[3]") back out? Where does the third book go, under which author, with what surrounding tags that the data class never described? The path tells the parser where to look, not how to build. Encoding is a binder's job, because a binder knows the whole structure. If you need to write XML, that is what xmlutil is for.
  • It does not validate against a schema. Out of scope.
  • Predicates only see attributes of the current element, never text content of a child — see the streaming reason above.

If you need encoding or schema validation, reach for a different tool. Predicates evaluating only on element entry is a design choice, not an oversight, but if you have a clean idea for a richer predicate language that preserves the streaming guarantee, PRs welcome.

How to try it

// Gradle, Kotlin
plugins {
    kotlin("jvm")
    id("com.google.devtools.ksp") version "2.3.7"
}
dependencies {
    implementation("site.asm0dey.xmlfluss:xml-fluss-runtime:0.0.0.3")
    ksp("site.asm0dey.xmlfluss:xml-fluss-ksp:0.0.0.3")
}

Enter fullscreen mode Exit fullscreen mode

// Gradle, Java records
dependencies {
    implementation("site.asm0dey.xmlfluss:xml-fluss-runtime:0.0.0.3")
    annotationProcessor("site.asm0dey.xmlfluss:xml-fluss-apt:0.0.0.3")
}

Enter fullscreen mode Exit fullscreen mode

The repo is at github.com/asm0dey/xml-fluss — README, more examples, full annotation reference, the lot. Issues and PRs welcome. If you try it on a real feed and something explodes, that is the most useful gift you can give me right now.

If you only need to encode XML, or you have a schema you fully control and a binding model fits your shape, please use xmlutil. Paul has put a lot of careful work into it and it shows.

But if you have ever found yourself writing a SAX ContentHandler at midnight, or modeling 47 wrapper classes to pull three fields out of a feed, give xml-fluss a look.

I might be on parser number four by then.