PHPackages                             alexoliverwd/sitemap-parser - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. alexoliverwd/sitemap-parser

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

alexoliverwd/sitemap-parser
===========================

A simple sitemap parser that makes parsing sitemaps easier.

1.0.1(1y ago)09MITPHPPHP &gt;=8.3CI passing

Since Feb 24Pushed 1y ago1 watchersCompare

[ Source](https://github.com/aoliverwd/sitemap-parser)[ Packagist](https://packagist.org/packages/alexoliverwd/sitemap-parser)[ RSS](/packages/alexoliverwd-sitemap-parser/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

Sitemap Parser Documentation
============================

[](#sitemap-parser-documentation)

Overview
--------

[](#overview)

The Sitemap Parser is a PHP class designed to parse XML sitemaps, whether they are local files or hosted URLs. It can handle both standard sitemaps and sitemap indexes, extracting location URLs and their last modification dates.

Class: `Parser`
---------------

[](#class-parser)

Namespace: `AOWD\SitemapParser`

Features
--------

[](#features)

- Parse XML sitemaps from local files or URLs
- Support for nested sitemaps (sitemap index files)
- Extract URL locations and last modification dates
- Built-in URL validation
- cURL-based URL content fetching
- Error handling with custom exceptions

Public Methods
--------------

[](#public-methods)

### `parser(string $sitemap_location): array`

[](#parserstring-sitemap_location-array)

The main method to parse a sitemap.

#### Parameters:

[](#parameters)

- `$sitemap_location`: String containing either a file path or URL to the sitemap

#### Returns:

[](#returns)

- Array of parsed entries, each containing:
    - `location`: The URL from the sitemap
    - `updated`: The last modification date

#### Example:

[](#example)

```
$entries = Parser::parser('https://example.com/sitemap.xml');
// or
$entries = Parser::parser('/path/to/local/sitemap.xml');
```

Error Handling
--------------

[](#error-handling)

The class uses a custom `ParserException` class for error handling. Exceptions are thrown for:

- Invalid XML content
- File reading errors
- URL fetching errors

Requirements
------------

[](#requirements)

- PHP 8.3 or higher
- cURL extension
- SimpleXML extension

Example Usage
-------------

[](#example-usage)

```
use AOWD\SitemapParser\Parser;
use AOWD\Exceptions\ParserException;

try {
    // Parse a sitemap
    $entries = Parser::parser('https://example.com/sitemap.xml');

    // Access the parsed entries
    foreach ($entries as $entry) {
        echo "URL: " . $entry['location'] . "\n";
        echo "Last Updated: " . $entry['updated'] . "\n";
    }
} catch (ParserException $e) {
    echo "Error: " . $e->getMessage();
}
```

Technical Details
-----------------

[](#technical-details)

### Entry Format

[](#entry-format)

Each parsed entry is stored as an associative array with the following structure:

```
[
    'location' => 'https://example.com/page',
    'updated' => '2023-01-01T12:00:00+00:00'
]
```

### Supported Sitemap Types

[](#supported-sitemap-types)

- Standard XML sitemaps
- Sitemap index files
- Nested sitemaps

### Validation

[](#validation)

- URL validation using `filter_var()`
- File extension checking (.xml)
- File existence verification for local files

Best Practices
--------------

[](#best-practices)

1. Always wrap parser calls in try-catch blocks
2. Verify sitemap file extensions
3. Ensure proper file permissions for local files
4. Handle potential network issues for remote sitemaps

Limitations
-----------

[](#limitations)

- Only supports XML format sitemaps
- Requires proper XML formatting
- Network dependent for remote sitemaps

This parser provides a robust solution for handling XML sitemaps in PHP applications, with built-in error handling and support for both local and remote sitemap files.

###  Health Score

30

—

LowBetter than 65% of packages

Maintenance47

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~44 days

Total

2

Last Release

394d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f94b7e714d61bd328ade45faeade1ed206cddc536d65cc2f5d526874b246576e?d=identicon)[alexoliverwd](/maintainers/alexoliverwd)

---

Top Contributors

[![aoliverwd](https://avatars.githubusercontent.com/u/37518812?v=4)](https://github.com/aoliverwd "aoliverwd (5 commits)")

---

Tags

xmlSitemap

###  Code Quality

TestsPest

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/alexoliverwd-sitemap-parser/health.svg)

```
[![Health](https://phpackages.com/badges/alexoliverwd-sitemap-parser/health.svg)](https://phpackages.com/packages/alexoliverwd-sitemap-parser)
```

###  Alternatives

[presta/sitemap-bundle

A Symfony bundle that provides tools to build your application sitemap.

3929.4M28](/packages/presta-sitemap-bundle)[rumenx/php-sitemap

Framework-agnostic Sitemap generator for PHP, Laravel, and Symfony.

1.3k15.1k1](/packages/rumenx-php-sitemap)[vipnytt/sitemapparser

XML Sitemap parser class compliant with the Sitemaps.org protocol.

772.2M10](/packages/vipnytt-sitemapparser)[ultrono/laravel-sitemap

Sitemap generator for Laravel 11, 12 and 13

36412.6k6](/packages/ultrono-laravel-sitemap)[demi/sitemap-generator

Yii2 component for generate sitemap.xml files.

1427.0k](/packages/demi-sitemap-generator)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
