JSPM

  • Created
  • Published
  • Downloads 128617
  • Score
    100M100P100Q167445F

Everyone loves JSON, and the world is moving that direction, but we still need things outputted in XML! Particularly for RSS and Podcast feeds. jstoxml makes it easy to contruct those feeds in JavaScript and output them to XML

Package Exports

  • jstoxml

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (jstoxml) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

jstoxml

Convert native JavaScript objects (JSON) to XML

Everyone loves JSON, and the world is moving that direction, but we still need things outputted in XML! Particularly for RSS and Podcasts.

This is inspired by node-jsontoxml, which was found to be a bit too rough around the edges. jstoxml attempts to fix that by being more flexible.

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):

var jstoxml = require('jstoxml');
{
  foo: 'bar',
  foo2: 'bar2'
}
<foo>bar</foo>
<foo2>bar2</foo2>
[
  {foo: 'bar'},
  {foo2: 'bar2'}
]
<foo>bar</foo>
<foo2>bar2</foo2>
[
  {name: 'foo', content: 'bar'},
  {name: 'foo2', content: 'bar2'}
];
<foo>bar</foo>
<foo2>bar2</foo2>
{
  'blah': '',
  foo: 'bar',
  'more blah': ''
}
blah
<foo>bar</foo>
more blah
{
  a: {
    foo: 'bar',
    foo2: 'bar2'
  }
}
<a>
  <foo>bar</foo>
  <foo2>bar2</foo2>
</a>
{
  date: function(){
    return new Date();
  }
}
<date>Sat Jul 30 2011 05:14:02 GMT+0900 (JST)</date>