abdolence/x2js

Produces invalid XML element names

Opened this issue · 1 comments

When converting from JSON to XML I get invalid XML element names such as <0> and that is not allowed. Perhaps they should be escaped in some way.

Example, this JSON:

   "deMag": [
      {
        "settings": {
          "generator": 1,
          "startCurrent": 5
        },
        "data": [ { } ]
      }
    ],

produce this XML:

    <deMag>
      <settings>
        <generator>1</generator>
        <startCurrent>5</startCurrent>
      </settings>
      <data>
        <$H>7535</$H>
      </data>
    </deMag>

JSON key with spaces produces incorrect results also,
i.e. "dosage amount" : 5 ==> <dosage amount>5</dosage amount>