Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with escape character " and ' conversion for json into an xml format. #714

Open
saba-firdos opened this issue Oct 24, 2024 · 0 comments

Comments

@saba-firdos
Copy link

saba-firdos commented Oct 24, 2024

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: &quot;aa&lt;31&amp;b21&apos;

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));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@saba-firdos and others