wankdanker / node-object-to-xml

Convert any JavaScript object to XML
MIT License
19 stars 8 forks source link

How to add multiple children, some with the same name #18

Closed harm-meijer closed 3 years ago

harm-meijer commented 3 years ago

When I parse the following:

{
  Index: {
    "#": [{ A: 1 }, { A: 2 }, { B1 }],
  },
};

I get:

<Index>
  <A>1</A>
</Index>
<Index>
  <A>2</A>
</Index>
<Index>
  <B>1</B>
</Index>

I would like to get the following xml:

<Index>
  <A>1</A>
  <A>2</A>
  <B>1</B>
</Index>

But can't figure out how to do this.

harm-meijer commented 3 years ago

This one is solved, used the following object to get desired xml:

{
  Index: {
    A: [1, 2],
    B: 1,
  },
}