-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 .root() on CheerioAPI object #4139
Comments
@doge247 This is because root() does not work as you would expect in XML mode. Fix: Get directly the element you want to change-it is actually the element-and then apply append() or prepend() on it. |
Even then, this is pretty janky n stuff, |
If you do want to append to a specific Node, you'll have to create a selection with that node first: errorDoc.root().children().append(`<message>yooo</message>`); // appends to the first child
console.log(errorDoc.xml()); // '<error><message>yoo</message></error>' |
It seems that cheerio cannot see the root element I've supplied and isn't wrapping the new element into the root as a result of that
And with
.append()
The text was updated successfully, but these errors were encountered: