soldair / node-jsontoxml

this renders a simple javascript object structure into xml/html. js objects are easier to modify than strings so no need to parse a whole dom to reliably add a few elements. while this could support async callbacks it doesn't. if people need it i will be happy to add support.
MIT License
101 stars 38 forks source link

cannot add attributes to a top level tag - (Alexander Scott Baron) #12

Closed soldair closed 11 years ago

soldair commented 11 years ago

Are you aware that you cannot add attributes to a top level xml tag in your library?

Example:

Children Shtuff

Thanks,

Alexander Scott Baron

thealexbaron commented 11 years ago

Example:

var values = { name: 'bar', attrs:{mood:'sad'}, children: { foo: 'bar' } };

jsontoxml(values);

soldair commented 11 years ago

have you tried?

var j = require('./jsontoxml');

console.log(j([{attrs:{a:"b"},name:"b"}]))

this works for me.

nodelists must be arrays of nodes because thats just how xml is

soldair commented 11 years ago
values = [
    {name: 'bar', attrs:{mood:'sad'}, children: {foo: 'bar'}}
];
soldair commented 11 years ago

im happy to help. close the issue if you feel it's resolved =)

thealexbaron commented 11 years ago

Thanks! Yes, this totally resolves my issue - not a bug on your end. A bug in my brian.