You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

rss-api

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rss-api

A series of useful APIs for xml(specially for RSS) and json

1.0.2
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

rss-api

A series of useful APIs for xml(specially for RSS) and json.

Version : 1.0.2

Author : Shaffer John

Installation

$ npm install rss-api

Usage

var rss = require('rss-api');

Example

var rss = require('rss-api');

var xml = 
'<?xml version="1.0" encoding="UTF-8" ?>'+
'<a test="123">'+
    '<b>456</b>'+
    '<c>789</c>'+
'</a>';

xml2json

**Prototype : ** xml2json = function(xml,callback)

  • callback is NOT necessary
var json = rss.xml2json(xml);
//output
/*
{
  "a": {
    "-test": "123", //"-" is a sign of attribution
    "b": "456",
    "c": "789"
  }
}
*/

//You can also use callback, for example:
rss.xml2json(xml, function(json){
    console.log(json);
});

json2xml

**Prototype : ** json2xml = function(json,isRSS,callback)

  • isRSS and callback is NOT necessary
  • Default for isRSS is false
var json = {a:{'-test':"123",b:"456",c:"789"}};
var xml = rss.json2xml(json);
//output
/*
<?xml version="1.0" encoding="UTF-8" ?>
<a test="123">
    <b>456</b>
    <c>789</c>
</a>
*/

//If you want to generate RSS:
var xml = rss.json2xml(json,true);
//output
/*
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
    <a test="123">
    <b>456</b>
    <c>789</c>
    </a>
</rss>
*/

//You can also use callback, for example:
rss.json2xml(json, false, function(xml){
    console.log(xml);
});

requestHTTP

**Prototype : ** requestHTTP = function(url, callback)

  • callback is necessary

This function is convenient for debug.

However it is NOT recommended for production environment.

Features

  • High performance
  • Simple
  • Openness

More information

Keywords

rss

FAQs

Package last updated on 05 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts