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

Non-latin characters get HTML-encoded with xml:true #4437

Open
zivni opened this issue Feb 25, 2025 · 1 comment
Open

Non-latin characters get HTML-encoded with xml:true #4437

zivni opened this issue Feb 25, 2025 · 1 comment

Comments

@zivni
Copy link

zivni commented Feb 25, 2025

The problem was resolved for HTML in #866.

When I use cheerio.load(xmlString, { xml: true }) it still gets encoded.

Is there a way to fix it?

@zivni
Copy link
Author

zivni commented Feb 25, 2025

I was able to fix it by using:

const dom = htmlparser2.parseDocument(xmlString, { xmlMode: true, decodeEntities: false });
const $ = cheerio.load(dom);
const out = $.html()

The only problem I see is that it removes the XML processing instructions. But I can concatenate them to the output.

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

No branches or pull requests

1 participant