xmlParseNodeInContext problems with an empty document When you call xmlParseNodeInContext on a fragment node with an empty document, the parser associates the first new node twice -- once with the document, and once with the fragment node. This fixes the issue by only associating the new node with the fragment node.