What would be the best way to check that my test XML contains a certain XML fragment?
For example, my main XML file has several <test-item> nodes, and my XML fragment defines a single <test-item> node.
I have managed by traversing the main document, creating a new Document for each <test-item> node, and comparing it to the XML fragment, so see if any of them match.
This seems a bit long winded, and I wondered if there is a better way to do it?
Not much better, but at least a bit:
Use the XPathEngine to get all test-item nodes rather than traversal. And then use DifferenceEngine's compare method directly which accepts two Node instances, you don't need to create new Documents that way.
I had the same use case and I have solved like bodewig suggested, but I do believe that an addition to the API for this scenario would be a great addition to this useful library.
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.