PHPackages                             mistralys/x4-savegame - 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. mistralys/x4-savegame

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

mistralys/x4-savegame
=====================

X4 savegame documentation and data files for XML structure reference

05PHP

Since Feb 7Pushed 3mo agoCompare

[ Source](https://github.com/Mistralys/x4-savegame)[ Packagist](https://packagist.org/packages/mistralys/x4-savegame)[ RSS](/packages/mistralys-x4-savegame/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

X4 Savegame
===========

[](#x4-savegame)

X4 savegame documentation and data files for XML structure reference.

Bundled Savegames
-----------------

[](#bundled-savegames)

- [X4 v8 - Scientist Start](saves/start-scientist-v8.xml.gz) - Game start - 369Mb XML
- [X4 v8 - Creative Advanced](saves/advanced-creative-v8.xml.gz) - 2 days play time - 704Mb XML

For each savegame, the extracted XML fragments (as sliced by the savegame parser) are included in a subfolder, in prettified XML format. This is a great resource to view the structure of the XML.

> NOTE: To keep the project small, the XML files are zipped.

Locating Nodes in the XML
-------------------------

[](#locating-nodes-in-the-xml)

For XML parsing tasks, you will often be looking for a specific node, and need to find out how exactly it is nested in the overall document structure. The bundled tool to extract tag ancestors is your friend in this case:

1. Identify the file and line number of the target XML tag.
2. Run the tool (see [Extractor Usage](#extractor-usage) below).
3. Use the generated file to view the tag's access path.

> NOTE: An example of this can be seen in [player locations](/docs/player-locations.md).

Adding Savegames
----------------

[](#adding-savegames)

1. Add the gz save file.
2. Commit to Git.

To also add the XML fragment files:

1. Switch to the savegame parser project.
2. Run `composer update` to load the new save file.
3. Add the save name in the `extract-test-saves.php` script.
4. Run the script.
5. Run the XML indenter on the XML files: `php bin/php/indent-xml.php .\tests\files\test-saves\{SAVE_FOLDER}\XML\ --replace`.
6. Copy the XML files over here into a folder for the save.
7. Compress the XML files to a 7z archive.
8. Commit the archive to Git.

Tools
-----

[](#tools)

### Extract Ancestor Path

[](#extract-ancestor-path)

A CLI tool to extract the complete ancestor chain of any XML element by line number. This is useful for navigating and documenting the complex nested structure of X4 savegame files without manually tracing through thousands of lines.

#### Installation

[](#installation)

First, install Composer dependencies and generate the autoloader:

```
composer install
```

#### Extractor Usage

[](#extractor-usage)

```
composer extract-ancestor-path --
```

**Arguments:**

- `xml-file` - Path to the XML savegame file (must be extracted, not .gz compressed)
- `line-number` - Line number of the target element (must be a complete opening tag)
- `output-file` - Path where the ancestor chain will be written

**Example:**

```
composer extract-ancestor-path -- saves/start-scientist-v8.xml 12345 output/player-location.xml
```

**Output Format:**

The tool generates a formatted XML file showing only the ancestor chain from the root element down to your target element, preserving all attributes and proper indentation:

```

```

**Requirements:**

- The XML file must be valid and prettified (one tag per line)
- The target line must contain a complete opening tag (not self-closing)
- PHP 8.0 or higher

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance58

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8895528?v=4)[Mistralys](/maintainers/Mistralys)[@Mistralys](https://github.com/Mistralys)

---

Top Contributors

[![Mistralys](https://avatars.githubusercontent.com/u/8895528?v=4)](https://github.com/Mistralys "Mistralys (20 commits)")

---

Tags

x4foundationsxmlxml-schema

### Embed Badge

![Health badge](/badges/mistralys-x4-savegame/health.svg)

```
[![Health](https://phpackages.com/badges/mistralys-x4-savegame/health.svg)](https://phpackages.com/packages/mistralys-x4-savegame)
```

###  Alternatives

[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k472.8M135](/packages/mtdowling-jmespathphp)[opis/closure

A library that can be used to serialize closures (anonymous functions) and arbitrary data.

2.6k230.0M283](/packages/opis-closure)[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M226](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M63](/packages/sabberworm-php-css-parser)[michelf/php-markdown

PHP Markdown

3.5k52.4M344](/packages/michelf-php-markdown)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)

PHPackages © 2026

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