Open dmbaturin opened 2 years ago
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.
Soup.insert_before
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".
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.
s
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.