davidcalhoun / jstoxml

JavaScript object to XML converter (useful for RSS, podcasts, GPX, AMP, etc)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

0-depth issues

davidcalhoun opened this issue · comments

There's some bugs in the code related to code at 0 depth outputting unexpected results, e.g.

const table = [
  {
    row: 'bar'
  },
  {
    row: 'bar2'
  }
];
const xmlOptions = {
  header: '<?xml version="1.0" encoding="UTF-16" standalone="yes"?>',
  indent: ' '
};

console.log(toXML(table, xmlOptions));

Outputs this:

<?xml version="1.0" encoding="UTF-16" standalone="yes"?>
<?xml version="1.0" encoding="UTF-16" standalone="yes"?>
<row>bar</row>
<?xml version="1.0" encoding="UTF-16" standalone="yes"?>
<row>bar2</row>

When it should output this:

<?xml version="1.0" encoding="UTF-16" standalone="yes"?>
<row>bar</row>
<row>bar2</row>

Reference: https://stackoverflow.com/questions/68130732/cant-add-header-info-properly-using-jstoxml