Description
I am converting a json into an xml using xml2js.Builder and without cdata true. All tags appear correctly, except the usage of “ and ‘ escape character situated inside the tags attributed.
The Builder library is able to convert < to < and & to &
The same does not work for “ which needs to converted as &quo; and ‘ should come as &apo; .
When used anywhere in the string for eg : "aa<31&b21' it is expected to get converted as: "aa<31&b21'
Sample code to test the library.
// Create a new instance of the Builder
const builder = new xml2js.Builder();
// JavaScript object with special characters
const obj = {
root: {
name: 'John< "Doe',
age: 30,
city: 'New York'
}
};
// Convert the JavaScript object to XML
console.log(builder.buildObject(obj));