Tuesday, 15 January 2013

javascript - What's the best JSON or JS object to XML converter module for Node JS -



javascript - What's the best JSON or JS object to XML converter module for Node JS -

i need build relatively simple xml document hierarchy , attributes js object. stand before choosing 1 of these modules:

https://github.com/davidcalhoun/jstoxml https://github.com/soldair/node-jsontoxml https://github.com/quickenloans/node-easyxml https://github.com/michaelkourlas/node-js2xmlparser

which module should pick?

this question dismissed beingness not question, don't know how inquire differently.

disclaimer: posted same question issue on each repository

this xml want build:

<?xml version="1.0" encoding="utf-8"?> <orders> <order> <order_orderid>123123</order_orderid> <order_customerid>345345</order_customerid> <order_senhcode>7604</order_senhcode> <order_mediacode>qwert</order_mediacode> <order_totalshippingcost>0</order_totalshippingcost> <order_paymentmethod>gb</order_paymentmethod> <order_paymentnumber /> <order_htmltext /> <order_comment /> <shippingmethodid>02</shippingmethodid> <order_creditcardnumber /> <order_creditcardnameholder /> <order_creditcardexpiredate /> <order_creditcardsafetycode /> <order_gifttext /> <inv_customer> <inv_customer_addresstypeid /> <inv_customer_gendermale>0</inv_customer_gendermale> <inv_customer_firstname>qwerty</inv_customer_firstname> <inv_customer_initials>q.w.e</inv_customer_initials> <inv_customer_prename /> <inv_customer_lastname>qwerty</inv_customer_lastname> <inv_customer_company>some company</inv_customer_company> <inv_customer_street>postbus</inv_customer_street> <inv_customer_housenumber>13</inv_customer_housenumber> <inv_customer_housenumberadditional /> <inv_customer_postalcode>1234 ab</inv_customer_postalcode> <inv_customer_city>there</inv_customer_city> <inv_customer_isocodecountry>nl</inv_customer_isocodecountry> <inv_customer_email>a@b.nl</inv_customer_email> <inv_customer_telephone>0168-123456</inv_customer_telephone> <inv_customer_mobilenr>06-12345678</inv_customer_mobilenr> </inv_customer> <orderlines> <orderline> <orderline_orderrecordid>1234</orderline_orderrecordid> <orderline_orderid>8765432</orderline_orderid> <orderline_articlenr>164-05-366</orderline_articlenr> <orderline_quantity>2</orderline_quantity> <orderline_productdescription>some gift voucher</orderline_productdescription> <orderline_price>1233</orderline_price> </orderline> <orderline> <orderline_orderrecordid>5678</orderline_orderrecordid> <orderline_orderid>8765432</orderline_orderid> <orderline_articlenr>164-05-367</orderline_articlenr> <orderline_quantity>3</orderline_quantity> <orderline_productdescription>some other gift voucher</orderline_productdescription> <orderline_price>1244</orderline_price> </orderline> </orderlines> </order> </orders>

i investigated myself

| author | davidcalhoun | soldair | quickenloans | michaelkourlas | |---------------|--------------|-----------|--------------|----------------| | module | jstoxml | node- | node- | node- | | | | jsontoxml | easyxml | js2xmlparser | | commits | 31 | 64 | 39 | 61 | | recent commit | year ago | 2 years ag| 6 months ago | 16 days ago | | contributors | 2 | 7 | 7 | 6 | | issues | 16 | 19 | 17 | 15 | | open issues | 7 | 1 | 6 | 1 | | npm install | jstoxml | not found | easyxml | js2xmlparser | | dependencies | none | none | elementtree, | none | | | | | inflect | | | throws errors | none | none | 3 | 12 |

then there's type of objects required compare

davidcalhoun/jstoxml:

{ "_name": 'foo', "_content": 'bar', "_attrs": { "a": 'b', "c": 'd' } }

soldair/node-jsontoxml: looks complicated

quickenloans/easyxml:

items: [{ "name": 'one', "_id": 1 }, { "name": 'two', "_id": 2 } ]

michaelkourlas/node-js2xmlparser

foo: { "#": 'bar', "@": { a: 'b', c: 'd' } }

i think i'll give michaelkourlas's node-js2xmlparser shot.

update: seems there 2 more worth mentioning:

chilts/data2xml oozcitak/xmlbuilder-js

the latter far matured , downloaded on npm. allows build xml in 1 go or iteratively.

javascript xml json node.js

No comments:

Post a Comment