<commit_before>jstoxml
=========
[![Build Status](https://travis-ci.org/davidcalhoun/jstoxml.svg?branch=master)](https://travis-ci.org/davidcalhoun/jstoxml)
[![Downloads][downloads-image]][npm-url]

### Convert JavaScript objects (and JSON) to XML (for RSS, Podcasts, etc.)

Everyone loves JSON, and more and more folks want to move that direction, but we still need things outputted in XML!  Particularly for [RSS feeds](http://www.rssboard.org/rss-specification) and [Podcasts](http://www.apple.com/itunes/podcasts/specs.html).

This is inspired by [node-jsontoxml](https://github.com/soldair/node-jsontoxml), which was found to be a bit too rough around the edges.  jstoxml attempts to fix that by being more flexible.

### Installation
* npm install jstoxml

### Changelog

#### Version 1.4.2
* support for handling arrays of primitives, instead of simply concatenating (#33)

#### Version 1.3.0
* restored `default` module export (#31)

#### Version 1.2.0
* refactoring and cleanup

#### Version 1.1.0
* Added support for attribute filtering (see Example 11b below).

#### Version 1.0.0
* Complete rewrite!  The code should now be easier to understand and maintain.
* now supports emoji/UTF8 tag attributes (needed for AMP pages - e.g. `<html ⚡ lang="en">`) (see example 14)
* now supports duplicate attribute key names (see example 15)
* Fixed: functions returning objects now have now that output passed through toXML for XML conversion
* Fixed: empty text strings now properly output self-closing tags
* Migrated tests to mocha

### Examples
First you'll want to require jstoxml in your script, and assign the result to the namespace variable you want to use (in this case jstoxml):

```javascript
// Node
const { toXML } = require('jstoxml');

// Browser
import { toXML } from 'jstoxml';
```

#### Example 1: Simple object
```javascript
toXML({
  foo: 'bar',
  foo2: 'bar2'<commit_msg>readme: add example for browser global usage (fixes #37)<commit_after>jstoxml
=========
[![Build Status](https://travis-ci.org/davidcalhoun/jstoxml.svg?branch=master)](https://travis-ci.org/davidcalhoun/jstoxml)
[![Downloads][downloads-image]][npm-url]

### Convert JavaScript objects (and JSON) to XML (for RSS, Podcasts, etc.)

Everyone loves JSON, and more and more folks want to move that direction, but we still need things outputted in XML!  Particularly for [RSS feeds](http://www.rssboard.org/rss-specification) and [Podcasts](http://www.apple.com/itunes/podcasts/specs.html).

This is inspired by [node-jsontoxml](https://github.com/soldair/node-jsontoxml), which was found to be a bit too rough around the edges.  jstoxml attempts to fix that by being more flexible.

### Installation
* npm install jstoxml

### Changelog

#### Version 1.4.2
* support for handling arrays of primitives, instead of simply concatenating (#33)

#### Version 1.3.0
* restored `default` module export (#31)

#### Version 1.2.0
* refactoring and cleanup

#### Version 1.1.0
* Added support for attribute filtering (see Example 11b below).

#### Version 1.0.0
* Complete rewrite!  The code should now be easier to understand and maintain.
* now supports emoji/UTF8 tag attributes (needed for AMP pages - e.g. `<html ⚡ lang="en">`) (see example 14)
* now supports duplicate attribute key names (see example 15)
* Fixed: functions returning objects now have now that output passed through toXML for XML conversion
* Fixed: empty text strings now properly output self-closing tags
* Migrated tests to mocha

### Examples
First you'll want to require jstoxml in your script, and assign the result to the namespace variable you want to use (in this case jstoxml):

```javascript
// Node
const { toXML } = require('jstoxml');

// Browser (with the help of something like Webpack or Rollup)
import { toXML } from 'jstoxml';

// Browser global fallback (requires no bundler)
var toXML = window.jstoxml.toXML;
```

#### Example 1: Simple object
```javascript
toXML({
  foo: 'bar',
  foo2: 'bar2'
{'fraction_non_alphanumeric': 0.12049407612805646, 'fraction_numerical': 0.015124779430299974, 'mean_word_length': 4.652421652421652, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 6, 'lorem ipsum': 0, 'www.': 4, 'xml': 23}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '548257', 'n_tokens_mistral': 1275, 'n_tokens_neox': 1194, 'n_words': 469}