Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsontoxml

Package Overview
Dependencies
Maintainers
0
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsontoxml

This renders a simple javascript object structure into reasonably complicated xml/html. js objects are easier to modify than strings so no need to parse a whole dom to reliably add a few elements

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
34K
decreased by-56.9%
Maintainers
0
Weekly downloads
 
Created
Source

This is a library designed to render js objects as xml. Its not made to parse or otherwise edit existing xml/html structures. For that and perhaps as a compliment to this you can use jsdom for editing existing markup.

Its real easy to make xml. I made this because i wanted to abstract away the fact that antiquated external systems require post data as xml and i wanted to expose a standard js calling api like my other interfaces. I did not want to instantiate an entire dom to perform simple updates to tags in lower level functions (like injecting api keys) when top level api call specific functions start building the xml string.

HOW TO INSTALL:

NPM:

npm install jsontoxml

Git:

git clone git://github.com/soldair/node-jsontoxml.git

HOW TO USE:

var jsonxml = require('jsonxml'); // if you "installed" with git // var jsonxml = require(path_to_jonxml+'/jsonxml');

jsonxml.obj_to_xml({ node:'text content', parent:[ {name:'taco',text:'beef taco',children:{salsa:'hot!'}}, {name:'taco',text:'fish taco',attrs:{mood:'sad'},children:[ {name:'salsa',text:'mild'}, 'hi', {name:'salsa',text:'weak',attrs:{type:2}} ]}, {name:'taco',attrs:'mood="party!"'} ], parent2:{ hi:'is a nice thing to say', node:'i am another not special child node' date:function(){ return (new Date())+''; } } })

outputs: // ! output is not tabbed this is an example

text content beef taco hot! fish taco mild hi weak is a nice thing to say i am another not special child node Sun Sep 26 2010 17:27:29 GMT-0700 (PDT)

FAQs

Package last updated on 11 Apr 2011

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc