A series of useful APIs for xml(specially for RSS) and json.
Version : 1.0.2
Author : Shaffer John
$ npm install rss-apivarrss=require('rss-api');varrss=require('rss-api');varxml='<?xml version="1.0" encoding="UTF-8" ?>'+'<a test="123">'+'<b>456</b>'+'<c>789</c>'+'</a>';**Prototype : **
xml2json = function(xml,callback)
callbackis NOT necessary
varjson=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);});**Prototype : **
json2xml = function(json,isRSS,callback)
isRSSandcallbackis NOT necessary- Default for
isRSSis false
varjson={a:{'-test':"123",b:"456",c:"789"}};varxml=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:varxml=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);});**Prototype : **
requestHTTP = function(url, callback)
callbackis necessary
This function is convenient for debug.
However it is NOT recommended for production environment.
- High performance
- Simple
- Openness