PHPackages                             jenwachter/data-encoder - 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. jenwachter/data-encoder

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

jenwachter/data-encoder
=======================

A PHP library to make it easier to create XML using the DOM Document object.

0.3(13y ago)016.3kMITPHPPHP &gt;=5.3.2

Since Feb 18Pushed 10y ago1 watchersCompare

[ Source](https://github.com/jenwachter/data-encoder)[ Packagist](https://packagist.org/packages/jenwachter/data-encoder)[ Docs](http://github.com/jenwachter/data-encoder)[ RSS](/packages/jenwachter-data-encoder/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (5)Used By (0)

DataEncoder
===========

[](#dataencoder)

Eventually this library will be built out to do various types of data encoding. For now, only XML and RSS are available.

XML Example
-----------

[](#xml-example)

Start out with an array of data structured the way you want the XML to be structured. Keep in mind that groups of objects should be included like the below array of "posts" where the key is the plural.

```
$data = array(
	"something" => "something",
	"posts" => array(
		array(
			"title" => "This is the title",
			"author" => array(
				"firstName" => "John",
				"lastName" => "Smith"
			),
			"url" => "http://www.somewebsite.com/path/to/article"
		),
		array(
			"title" => "This is the title of another article",
			"author" => array(
				"firstName" => "Jane",
				"lastName" => "Doe"
			),
			"url" => "http://www.somewebsite.com/path/to/this/article"
		)
	)
);
```

Then create a new XML Encoder object, passing it the array of data. After that, it's as easy as calling the `render()` method.

```
$xml = new \DataEncoder\XML($data);
$xml->render();
```

RSS Example
-----------

[](#rss-example)

The process for creating an RSS feed is a bit different, as RSS feeds have very specific requirements. When instantiating a new RSS Encoder, there are three required and one optional parameter. For this example, I'll show the method calls and then describe each parameter.

```
$xml = new \DataEncoder\RSS($channelElements, $itemElements, $data, $dataMap);
$xml->render();
```

### $channelElements

[](#channelelements)

An associative array of channel elements. Please note that per RSS specification, "title," "link," and "description" elements are required. Optional elements include "lastBuildDate," "language," etc...

```
$channelElements = array(
	"title" => "The Title of my feed",
	"link" => "http://www.google.com",
	"description" => "The description of my feed",
	"lastBuildDate" => 1361242244
);
```

### $itemElements

[](#itemelements)

To prevent a whole lot of processing before even instantiating the RSS Encoder to only pass the fields you want to include in the feed, the second parameter allows you to pick and choose which elements you want to include. Please note that these values correspond to the $dataMap array first and then to the item keys passed in through $data.

```
$itemElements = array("id", "title", "description", "link", "comments", "pubDate");
```

### $data

[](#data)

An array of items in the feed.

```
$data = array(
	array(
		"title" => "This is the title",
		"author" => array(
			"firstName" => "John",
			"lastName" => "Smith"
		),
		"url" => "http://www.somewebsite.com/path/to/article"
	),
	array(
		"title" => "This is the title of another article",
		"author" => array(
			"firstName" => "Jane",
			"lastName" => "Doe"
		),
		"url" => "http://www.somewebsite.com/path/to/this/article"
	)
);
```

### $dataMap

[](#datamap)

In further effort to prevent a lot of processing before even instantiating the RSS Encoder, the final (and optional) parameter is an associative array mapping fields in the items passed $data array to RSS-specific fields.

```
$dataMap = array(
	"headline" => "title",
	"body" => "description",
	"url" => "link",
	"publish_date" => "pubDate"
);
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

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 ~24 days

Total

4

Last Release

4765d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/11e1b915549459b87bab747538857fb810a047407ad1a0eeee929e23908d5490?d=identicon)[jenwachter](/maintainers/jenwachter)

---

Top Contributors

[![jenwachter](https://avatars.githubusercontent.com/u/1202305?v=4)](https://github.com/jenwachter "jenwachter (23 commits)")

---

Tags

xmlrssdom document

### Embed Badge

![Health badge](/badges/jenwachter-data-encoder/health.svg)

```
[![Health](https://phpackages.com/badges/jenwachter-data-encoder/health.svg)](https://phpackages.com/packages/jenwachter-data-encoder)
```

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[jms/serializer

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

2.3k135.8M851](/packages/jms-serializer)[jms/metadata

Class/method/property metadata management in PHP

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

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

1.8k89.3M627](/packages/jms-serializer-bundle)[sabre/xml

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

52832.2M131](/packages/sabre-xml)[goetas-webservices/xsd2php

Convert XSD (XML Schema) definitions into PHP classes and JMS metadata

2411.6M37](/packages/goetas-webservices-xsd2php)

PHPackages © 2026

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