michaelkourlas / node-js2xmlparser

Popular Node.js module for parsing JavaScript objects into XML
https://www.npmjs.org/package/js2xmlparser
Apache License 2.0
221 stars 52 forks source link

Wrapping Arrays #51

Closed oprogfrogo closed 7 years ago

oprogfrogo commented 7 years ago

Using your package, how do I wrap an array so that this:

items: [ '1', '2', '3', '4' ]

becomes this:

<items type="array">
    <item>1</item>
    <item>2</item>
    <item>3</item>
    <item>4</item>
  </items>
davidjr commented 7 years ago

redacted....

michaelkourlas commented 7 years ago

@oprogfrogo The following object should produce the desired output

var obj = {
    items: {
        "@": {
            type: "array"
        },
        "item": ["1", "2", "3", "4"]
    }
}