Skip to content

Creating mixed content #6

Open
@sshivananda

Description

@sshivananda

I am trying to model classes that can support mixed content. From the example at https://www.npmjs.com/package/js2xmlparser I could do this with

var js2xmlparser = require("js2xmlparser");
 
var obj = {
    "phone": [
        {
            "@": {
                "type": "home"
            },
            "#": "123-555-4567"
        },
        {
            "@": {
                "type": "cell"
            },
            "#": "890-555-1234"
        }
    ],
    "email": "john@smith.com"
};
 
console.log(js2xmlparser.parse("person", obj));

which gives me an xml

<?xml version='1.0'?>
<person>
    <phone type='home'>123-555-4567</phone>
    <phone type='cell'>890-555-1234</phone>
    <email>john@smith.com</email>
</person>

How would I go about doing this using xml-decorators?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions