Skip to content

Cannot serialize arrays #191

@miloush

Description

@miloush

Any time I try to convert an array to XML, I get Uncaught Error HierarchyRequestError: The operation would yield an incorrect node tree. Document already has a document element node.

To Reproduce

var a1 = [1, 2, 4];
var a2 = [{ p: "v" }, { p: "v" }];
var a3 = { a: [{ p: "v" }, { p: "v" }] };

var doc = create(a1).end();

Expected behavior
To be able to serialize arrays and objects with arrays into xml. Make up elements if there isn't objects.

<items>
  <item>1</item>

or

<array>
  <item>
    <p>v</p>
  </item>

or

<a>
 <p>v</p>
</a>
<a>
 <p>v</p>
</a>

Version:

  • node.js: 23.11
  • xmlbuilder2 3.1.0

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions