PHPackages                             jan-drda/pure-php-xml-writer - 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. jan-drda/pure-php-xml-writer

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

jan-drda/pure-php-xml-writer
============================

Simple XML writer library written with basic PHP functions only.

0.2.3(6y ago)62551[1 issues](https://github.com/jdrda/pure-php-xml-writer/issues)MITPHP

Since Oct 30Pushed 5y ago3 watchersCompare

[ Source](https://github.com/jdrda/pure-php-xml-writer)[ Packagist](https://packagist.org/packages/jan-drda/pure-php-xml-writer)[ Docs](https://github.com/jdrda/pure-php-xml-writer)[ RSS](/packages/jan-drda-pure-php-xml-writer/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (9)DependenciesVersions (10)Used By (0)

[![License](https://camo.githubusercontent.com/aeb8f0e9663a5d9b82165a0e98c7448dafdcca50f1115d600939cd2158d0c679/68747470733a2f2f706f7365722e707567782e6f72672f6a616e2d647264612f707572652d7068702d786d6c2d7772697465722f6c6963656e7365)](https://packagist.org/packages/jan-drda/pure-php-xml-writer)[![Latest Stable Version](https://camo.githubusercontent.com/ece630a450dfbd03c2020695f77054afe1b6de6480f277adf1cd625a33c8e6c2/68747470733a2f2f706f7365722e707567782e6f72672f6a616e2d647264612f707572652d7068702d786d6c2d7772697465722f762f737461626c65)](https://packagist.org/packages/jan-drda/pure-php-xml-writer)[![Total Downloads](https://camo.githubusercontent.com/a1ef58dd1c43e2de9f02992f8cab6055e2300e84e600cceb0ab5305e66853c1b/68747470733a2f2f706f7365722e707567782e6f72672f6a616e2d647264612f707572652d7068702d786d6c2d7772697465722f646f776e6c6f616473)](https://packagist.org/packages/jan-drda/pure-php-xml-writer)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/7d501da45a5fb5f4d19f4535463c3fb2e1cfc17c4a564b49bd19294532983374/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a647264612f707572652d7068702d786d6c2d7772697465722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/jdrda/pure-php-xml-writer/?branch=master) [![Build Status](https://camo.githubusercontent.com/bb5a311207bda6a25be761b8967a0b7ccc133cb7ec419d3d75f3d24090c615cc/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a647264612f707572652d7068702d786d6c2d7772697465722f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/jdrda/pure-php-xml-writer/build-status/master)

Pure PHP XML Writer
===================

[](#pure-php-xml-writer)

Simple XML writer library written with basic PHP functions only. The main purpose of this project is generating large XML files without using large amount of memory (all elements are passed to the write buffer, there is no object containing all the XML in memory).

[![ko-fi](https://camo.githubusercontent.com/3083b1b9120d3820370812846fe8349310dbba940baa14700d89db51b80a2629/68747470733a2f2f7777772e6b6f2d66692e636f6d2f696d672f646f6e6174655f736d2e706e67)](https://ko-fi.com/A067ES5)

Installation
------------

[](#installation)

```
composer require jan-drda/pure-php-xml-writer

```

Then copy example.php to your project root directory. You can modify it upon your requirements and run.

### If you do not have Composer

[](#if-you-do-not-have-composer)

Install it, it is very simple:

Documentantion
--------------

[](#documentantion)

Please see example.php for basic usage, I am working at documentation (copying there):

```
/**
 * Composer autoload (only if you do not use it anywhere else)
 *
 * It is needed for namespace mapping
 */
require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php');

/**
 * Simple initialize XML Writer and auto open the file
 */
$xmlWriter = new \PurePhpXmlWriter\PurePhpXmlWriter('feed.xml');

/**
 * Open root element "items" (true = expecting children elements)
 */
$xmlWriter->openXMLElement('products', true);

/**
 * Save simple product
 */
$xmlWriter->openXMLElement('product', true); // Open the parent element
$xmlWriter->saveElementWithValue('name', 'Breakfast white mug'); // Name
$xmlWriter->saveElementWithValue('description', 'Nice white mug used for breakfast'); // Description
$xmlWriter->saveElementWithValue('price', 5.00, 2); // Price with 2 decimals
$xmlWriter->saveElementWithValue('category', 'Mugs|Breakfast'); // Category
$xmlWriter->saveElementWithValue('quantity', 20); // Quantity available
$xmlWriter->closeXMLElement('product'); // Close the parent element

/**
 * /Save simple product
 */

/**
 * Save variable product where variants have individual prices
 */
$xmlWriter->openXMLElement('product', true); // Open the parent element
$xmlWriter->saveElementWithValue('name', 'Puma T-shirt'); // Name
$xmlWriter->saveElementWithValue('description', 'Puma t-shirt with some sizes'); // Description
$xmlWriter->saveElementWithValue('price', 10.00, 2); // Price with 2 decimals
$xmlWriter->saveElementWithValue('category', 'T-shirts|Nike'); // Category
$xmlWriter->saveElementWithValue('quantity', 10); // Quantity available
$xmlWriter->openXMLElement('sizes', true); // Open the parent element for sizes

// Small size
$xmlWriter->openXMLElement('size', true); // Open the parent element for size
$xmlWriter->saveElementWithValue('size_name', 'S'); // Size name
$xmlWriter->saveElementWithValue('size_price', 10.00); // Size price with 2 decimals
$xmlWriter->closeXMLElement('size', true); // Open the parent element for size

// Medium size
$xmlWriter->openXMLElement('size', true); // Open the parent element for size
$xmlWriter->saveElementWithValue('size_name', 'M'); // Size name
$xmlWriter->saveElementWithValue('size_price', 11.00); // Size price with 2 decimals
$xmlWriter->closeXMLElement('size', true); // Open the parent element for size

// Large size
$xmlWriter->openXMLElement('size', true); // Open the parent element for size
$xmlWriter->saveElementWithValue('size_name', 'L'); // Size name
$xmlWriter->saveElementWithValue('size_price', 13.00); // Size price with 2 decimals
$xmlWriter->closeXMLElement('size', true); // Open the parent element for size
$xmlWriter->closeXMLElement('sizes', true); // Close the parent element for sizes
$xmlWriter->closeXMLElement('product'); // Close the parent element

/**
 * /Save variable product
 */

/**
 * Close root element "items"
 */
$xmlWriter->closeXMLElement('products');
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96.4% 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 ~39 days

Recently: every ~74 days

Total

9

Last Release

2478d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/145ef2492c7f6c9a5694927313b81b242de09cc8b2d1e3bb4343a88ce32ac6df?d=identicon)[jdrda](/maintainers/jdrda)

---

Top Contributors

[![jdrda](https://avatars.githubusercontent.com/u/7347494?v=4)](https://github.com/jdrda "jdrda (27 commits)")[![Albertcuicas](https://avatars.githubusercontent.com/u/6081570?v=4)](https://github.com/Albertcuicas "Albertcuicas (1 commits)")

---

Tags

xmlxml writerpure-php

### Embed Badge

![Health badge](/badges/jan-drda-pure-php-xml-writer/health.svg)

```
[![Health](https://phpackages.com/badges/jan-drda-pure-php-xml-writer/health.svg)](https://phpackages.com/packages/jan-drda-pure-php-xml-writer)
```

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k260.4M292](/packages/masterminds-html5)[jms/serializer

Library for (de-)serializing data of any complexity; supports XML, and JSON.

2.3k139.8M905](/packages/jms-serializer)[jms/metadata

Class/method/property metadata management in PHP

1.8k157.6M95](/packages/jms-metadata)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k91.4M664](/packages/jms-serializer-bundle)[sabre/xml

sabre/xml is an XML library that you may not hate.

52933.7M139](/packages/sabre-xml)[presta/sitemap-bundle

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

3839.8M35](/packages/presta-sitemap-bundle)

PHPackages © 2026

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