Given an XML document and an XPath expression, I want to create a new document which has all of the nodes of the original document with the exception of the nodes selected by the XPath expression, effectively giving the result of a subtract filter.
My idea was to use the xmlXpathEvalExpression() function, and for each node in the root document tree, copy the node over unless the node matches the returned xmlNodeSet. However, libxml2 gives no hints about how, or even if, nodes can be tested for equality.
Are you supposed to compare the pointers to the nodes in the returned set? Or are you supposed to compare the given node names/namespaces?