Skill Issue: Filtering an XML File with at Least 2 Conditions
I feel you. You’re a developer and still can’t filter an XML file with two conditions. Same here. I was in that boat. So I built a tool for it.
GitHub: https://github.com/duhanmeric/feed-filter
Before diving into the story, let’s define what a “feed” is. It’s usually an XML file with structured product data. Things like ID, name, price, image URL, availability, etc. These feeds are commonly used by online stores to share their inventory with marketing platforms or marketplaces.
A typical feed looks like this:
<rss>
<channel>
<item>
<id>9778</id>
</item>
<!-- more items -->
</channel>
</rss>
Each <item>
contains product attributes but the tag names and structure can vary. So hardcoding filters isn’t ideal.
Why I Started This Project
A few weeks ago, I got a message from a customer:
“You’re showing 14 products in category X with price above Y, but it should be 16. Where are the other 2?”
They had 8000+ products in their feed. I needed to filter it but using third-party tools on such a large XML was painful. Laggy, slow, confusing. I quickly wrote a script with ChatGPT’s help.
Downsides?
- You had to hardcode the path to
<item>
- You had to hardcode the filter conditions
Even so, it solved my task. But I knew this kind of work would keep popping up and it would keep wasting our time. So I started thinking about building feed-filter.
Goal
I wanted a tool that lets you:
- Enter a URL of any XML feed
- Choose filter conditions from a generated list
- See filtered results in the UI
No need to know tag names or XML structure. The app would handle that.
I wasn’t sure if this was technically feasible. So I went with the tool I knew best: React (Next.js).
That was… a mistake.
Algorithm
Basic flow of the app:
- User enters feed URL
- Server fetches and parses the XML
- It creates a folder in
src/uploadedFiles/<uuid>
and saves the XML there - It extracts available
<item>
keys and stores them as a.json
- UI lists those keys for filter selection
- After applying filters, the result is written to a new
.json
and shown in the UI with pagination
Here’s how it works:
Why Not in Production?
Because of serverless limitations.
Vercel (and similar platforms) don’t allow reliable fs
read/write. I could have dockerized the app and deployed it to a VPS but that felt overkill for a niche tool. So I kept it as a local dev-only tool.
Why Not XPath?
Yes, XPath is powerful. But:
- It’s not user-friendly. Writing queries requires knowledge
- It needs namespaces to be defined and feeds can vary wildly
With XPath I could avoid saving .json
files entirely and get better performance, but I wanted flexibility and simplicity for the user.