I need to find a particular node in an xml file, <example>Some text</example>
Then I want to extract this node and it's subelements from the xml file and write it into a new xml file and I then need to extract the other remaining xml nodes in the original xml file minus the extracted node into the new xml file following the extracted node.
How can I do this with xslt or xpath?
Best Answer
Here is how to output all nodes minus the specific node and its subtree:
when this transformation is applied on the following XML document (none was provided!):
the wanted, correct result is produced:
Here is how to extract only the wanted node and its subtree:
when applied on the same XML document (above), the result now is:
Two different result documents cannot be produced in a single XSLT 1.0 transformation.
Here is an XSLT 2.0 transformation that outputs the first result and writes to a file the second result: