-
-
Notifications
You must be signed in to change notification settings - Fork 340
Closed
Description
- Are you running the latest version?
- Have you included sample input, output, error, and expected output?
- Have you checked if you are using correct configuration?
- Did you try online tool?
Description
When XMLBuilder is created with both the format and preserveOrder options enabled, the xml string that it produces has values on a separate line and indented. In addition, it adds a newline at the beginning of output.
Code
const XMLdata = `
<car>
<color>purple</color>
<type>minivan</type>
<registration>2020-02-03</registration>
<capacity>7</capacity>
</car>
`;
const parser = new XMLParser({preserveOrder: true});
const builder = new XMLBuilder({preserveOrder: true, format: true});
const output = builder.build(parser.parse(XMLdata));
console.log(output);Output
<car>
<color>
purple
</color>
<type>
minivan
</type>
<registration>
2020-02-03
</registration>
<capacity>
7
</capacity>
</car>
expected data
<car>
<color>purple</color>
<type>minivan</type>
<registration>2020-02-03</registration>
<capacity>7</capacity>
</car>Metadata
Metadata
Assignees
Labels
No labels