georgebakoulis.dev

Building Pharos: Parsing sitemap.xml into something useful

I'm building a CLI to turn my content into files AI agents can read.

It's called Pharos, and I'm starting with my own site as the test subject. It scans the content and generates the files agents need to consume. In every post of this series I'll link the branch, so you can see exactly what changed.

Let's start with the first step.

Making the sitemap.xml into an array of objects

Problem: I have a long xml file and I want to extract the urls and the last modified dates from it.

Branch: https://github.com/bak-george/Pharos/tree/first-setup

Pull the urls and lastmod out of every <url> tag

I've begun with the absolute basics, so in the first pull request I'm fetching the urls and the modified dates from the sitemap.xml.

Input:

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" ...>
<url>
<loc>https://georgebakoulis.dev/blog/coding-books-or-courses</loc>
<lastmod>2026-03-22T18:02:03+00:00</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
<loc>https://georgebakoulis.dev/blog/journey-into-ambient-music</loc>
<lastmod>2026-03-22T18:02:03+00:00</lastmod>
<changefreq>monthly</changefreq>
</url>
<!-- The rest of the file -->
</urlset>

Output:

[
  {
    url: 'https://georgebakoulis.dev/blog/coding-books-or-courses',
    lastmod: '2026-03-22T18:02:03+00:00'
  },
  {
    url: 'https://georgebakoulis.dev/blog/journey-into-ambient-music',
    lastmod: '2026-03-22T18:02:03+00:00'
  },
  {
    url: 'https://georgebakoulis.dev/blog/brand-new-2015-macbook-air',
    lastmod: '2026-03-22T18:02:03+00:00'
  },
  // rest of the objects
]

Small step, but it's the foundation. Next up: fetching the actual content behind every url.