The problem of converting node json to xml

use xml2js to convert json to xml, when a null value exists, the conversion fails

related codes

const  xml2js = require("xml2js");
let obj = {name: "Super", Surname: "Man", age: 23,dd:"",ll:""};
let  builder = new xml2js.Builder();
let xml = builder.buildObject(obj);
console.log( xml);

output result:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
  <name>Super</name>
  <Surname>Man</Surname>
  <age>23</age>
  <dd/>
  <ll/>
</root>

there are only half of dd and ll here. Is that how everyone deals with them?

Nov.29,2021

isn't this a success? < dd/ > and < dd > < / dd > don't mean the same thing?

Menu