All Projects → michaelkourlas → Node Js2xmlparser

michaelkourlas / Node Js2xmlparser

Licence: apache-2.0
Popular Node.js module for parsing JavaScript objects into XML

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Node Js2xmlparser

Gelatin
Transform text files to XML, JSON, or YAML
Stars: ✭ 150 (-12.28%)
Mutual labels:  json, xml, converter
Goxml2json
XML to JSON converter written in Go (no schema, no structs)
Stars: ✭ 170 (-0.58%)
Mutual labels:  json, xml, converter
Exportsheetdata
Add-on for Google Sheets that allows sheets to be exported as JSON or XML.
Stars: ✭ 170 (-0.58%)
Mutual labels:  json, xml
Cfgdiff
diff(1) all your configs
Stars: ✭ 138 (-19.3%)
Mutual labels:  json, xml
Omniparser
omniparser: a native Golang ETL streaming parser and transform library for CSV, JSON, XML, EDI, text, etc.
Stars: ✭ 148 (-13.45%)
Mutual labels:  json, xml
Any Json
Convert (almost) anything to JSON
Stars: ✭ 128 (-25.15%)
Mutual labels:  json, converter
Scobot
SCORM API for Content. JavaScript library, QUnit tests and examples.
Stars: ✭ 128 (-25.15%)
Mutual labels:  json, xml
Restclient.net
.NET REST Client Framework for all platforms
Stars: ✭ 143 (-16.37%)
Mutual labels:  json, xml
Repurrrsive
Recursive lists to use in teaching and examples, because there is no iris data for lists.
Stars: ✭ 112 (-34.5%)
Mutual labels:  json, xml
Serializer
With the Serializer component it's possible to handle serializing data structures, including object graphs, into array structures or other formats like XML and JSON. It can also handle deserializing XML and JSON back to object graphs.
Stars: ✭ 2,021 (+1081.87%)
Mutual labels:  json, xml
Uxdm
🔀 UXDM helps developers migrate data from one system or format to another.
Stars: ✭ 159 (-7.02%)
Mutual labels:  json, xml
Snodge
Randomly mutate JSON, XML, HTML forms, text and binary data for fuzz testing
Stars: ✭ 121 (-29.24%)
Mutual labels:  json, xml
Fetch Plus
🐕 Fetch+ is a convenient Fetch API replacement with first-class middleware support.
Stars: ✭ 116 (-32.16%)
Mutual labels:  json, xml
Oq
A performant, and portable jq wrapper to facilitate the consumption and output of formats other than JSON; using jq filters to transform the data.
Stars: ✭ 132 (-22.81%)
Mutual labels:  json, xml
Marklogic Data Hub
The MarkLogic Data Hub: documentation ==>
Stars: ✭ 113 (-33.92%)
Mutual labels:  json, xml
Autocser
AutoCSer is a high-performance RPC framework. AutoCSer 是一个以高效率为目标向导的整体开发框架。主要包括 TCP 接口服务框架、TCP 函数服务框架、远程表达式链组件、前后端一体 WEB 视图框架、ORM 内存索引缓存框架、日志流内存数据库缓存组件、消息队列组件、二进制 / JSON / XML 数据序列化 等一系列无缝集成的高性能组件。
Stars: ✭ 140 (-18.13%)
Mutual labels:  json, xml
Kripton
A Java/Kotlin library for Android platform, to manage bean's persistence in SQLite, SharedPreferences, JSON, XML, Properties, Yaml, CBOR.
Stars: ✭ 110 (-35.67%)
Mutual labels:  json, xml
Bible Database
Bible databases as XML, JSON, SQL & SQLITE3 Database format for various languages. Developers can download it freely for their development works. Freely received, freely give.
Stars: ✭ 111 (-35.09%)
Mutual labels:  json, xml
Configurate
A simple configuration library for Java applications providing a node structure, a variety of formats, and tools for transformation
Stars: ✭ 148 (-13.45%)
Mutual labels:  json, xml
Xresloader
跨平台Excel导表工具(Excel=>protobuf/msgpack/lua/javascript/json/xml)
Stars: ✭ 161 (-5.85%)
Mutual labels:  json, xml

js2xmlparser

Node.js CI npm version

Overview

js2xmlparser is a Node.js module that parses JavaScript objects into XML.

Features

Since XML is a data-interchange format, js2xmlparser is designed primarily for JSON-type objects, arrays and primitive data types, like many of the other JavaScript to XML parsers currently available for Node.js.

However, js2xmlparser is capable of parsing any object, including native JavaScript objects such as Date and RegExp, by taking advantage of each object's toString function or, if this function does not exist, the String constructor.

js2xmlparser also has support for the Map and Set objects introduced in ECMAScript 2015, treating them as JSON-type objects and arrays respectively. Support for Maps is necessary to generate XML with elements in a specific order, since JSON-type objects do not guarantee insertion order. Map keys are always converted to strings using the method described above.

js2xmlparser also supports a number of constructs unique to XML:

  • attributes (through an attribute property in objects)
  • mixed content (through value properties in objects)
  • multiple elements with the same name (through arrays)

js2xmlparser can also pretty-print the XML it outputs.

Installation

The easiest way to install js2xmlparser is using npm:

npm install js2xmlparser

You can also build js2xmlparser from source using npm:

git clone https://github.com/michaelkourlas/node-js2xmlparser.git
npm install
npm run-script build

The build script will build the production variant of js2xmlparser, run all tests, and build the documentation.

You can build the production variant without running tests using the script prod. You can also build the development version using the script dev. The only difference between the two is that the development version includes source maps.

Usage

The documentation for the current version is available here.

You can also build the documentation using npm:

npm run-script docs

Examples

The following example illustrates the basic usage of js2xmlparser:

var js2xmlparser = require("js2xmlparser");

var obj = {
    firstName: "John",
    lastName: "Smith",
    dateOfBirth: new Date(1964, 7, 26),
    address: {
        "@": {
            type: "home",
        },
        "streetAddress": "3212 22nd St",
        "city": "Chicago",
        "state": "Illinois",
        "zip": 10000,
    },
    phone: [
        {
            "@": {
                type: "home",
            },
            "#": "123-555-4567",
        },
        {
            "@": {
                type: "cell",
            },
            "#": "890-555-1234",
        },
        {
            "@": {
                type: "work",
            },
            "#": "567-555-8901",
        },
    ],
    email: "[email protected]",
};

console.log(js2xmlparser.parse("person", obj));

This example produces the following XML:

<?xml version='1.0'?>
<person>
    <firstName>John</firstName>
    <lastName>Smith</lastName>
    <dateOfBirth>Wed Aug 26 1964 00:00:00 GMT-0400 (Eastern Summer Time)</dateOfBirth>
    <address type='home'>
        <streetAddress>3212 22nd St</streetAddress>
        <city>Chicago</city>
        <state>Illinois</state>
        <zip>10000</zip>
    </address>
    <phone type='home'>123-555-4567</phone>
    <phone type='cell'>890-555-1234</phone>
    <phone type='work'>567-555-8901</phone>
    <email>[email protected]</email>
</person>

Additional examples can be found in the examples directory.

Tests

js2xmlparser includes a set of tests to verify core functionality. You can run the tests using npm:

npm run-script test-prod

The only difference between the test-prod and test-dev scripts is that the development version includes source maps.

License

js2xmlparser is licensed under the Apache License 2.0. Please see the LICENSE file for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].