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?
Thanks,
Tamsin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
t
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
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?
Thanks,
Tamsin
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.
t