diff --git a/xml/document.go b/xml/document.go
index <HASH>..<HASH> 100644
--- a/xml/document.go
+++ b/xml/document.go
@@ -31,6 +31,7 @@ type Document interface {
 	OutputEncoding() []byte
 	DocXPathCtx() *xpath.XPath
 	AddUnlinkedNode(unsafe.Pointer)
+	RemoveUnlinkedNode(unsafe.Pointer) bool
 	Free()
 	String() string
 	Root() *ElementNode
@@ -167,6 +168,15 @@ func (document *XmlDocument) AddUnlinkedNode(nodePtr unsafe.Pointer) {
 	document.UnlinkedNodes[p] = true
 }
 
+func (document *XmlDocument) RemoveUnlinkedNode(nodePtr unsafe.Pointer) bool {
+	p := (*C.xmlNode)(nodePtr)
+	if document.UnlinkedNodes[p] {
+		delete(document.UnlinkedNodes, p)
+		return true
+	}
+	return false
+}
+
 func (document *XmlDocument) BookkeepFragment(fragment *DocumentFragment) {
 	document.fragments = append(document.fragments, fragment)
 }
add a function to allow removal of unlinked node to be added back