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

Trying to insert a node before a child of the root fails #46

Open
dmbaturin opened this issue Feb 2, 2022 · 1 comment
Open

Trying to insert a node before a child of the root fails #46

dmbaturin opened this issue Feb 2, 2022 · 1 comment

Comments

@dmbaturin
Copy link
Contributor

Soup.insert_before only works if the node is a child of an element node, but it fails when the node is at the root of the element tree.

utop # #require "lambdasoup";;

utop # open Soup.Infix;;

utop # let s = Soup.parse "<p>test element</p>" ;;

utop # Soup.insert_before (s $ "p") (Soup.create_text "test stuff") ;;
Exception: Failure "Soup.insert_before: target node has no parent".
@aantron
Copy link
Owner

aantron commented Jul 25, 2024

I think in order to solve this, the root element node s would have to be replaced by a soup node that has s as a child. Then the new node can be inserted before that child.

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

2 participants