Closed NickolasHu closed 7 years ago
I believe what you are attempting to do is currently possible.
Assumed desired result:
<template>
<div style="width:137; height:315">
<div style="width:137; height:141; left:0.0; top:0.0; background-color:#d7d7d7; border-width:2; border-color:#969696" />
<div style="width:137; height:141; left:0.0; top:174.0; background-color:#d7d7d7; border-width:2; border-color:#969696" />
</div>
</template>
Object that generates the above result:
var o2x = require('object-to-xml');
const template = {
"template": {
"div": {
"@": {
"style": "width:137; height:315"
},
"#": {
"div": [
{
"@": {
"style": "width:137; height:141; left:0.0; top:0.0; background-color:#d7d7d7; border-width:2; border-color:#969696"
}
},
{
"@": {
"style": "width:137; height:141; left:0.0; top:174.0; background-color:#d7d7d7; border-width:2; border-color:#969696"
}
}
]
}
}
}
};
console.log(o2x(template));
Hi, when converting object bellow. The node with children lost.
Result:
Thanks.