Forum Discussion
Hi,
You could certainly do this with a Script Assertion, but in terms of XQuery is what you're looking for something like this:
1) You have something like:
<diffgr:diffgram xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<NewDataSet xmlns="">
<Status diffgr:id="Status12" msdata:rowOrder="11">
<id>28</id>
<name>Review1</name>
<categoryId>3</categoryId>
<assignrule>P</assignrule>
<ismoveAssign>0</ismoveAssign>
<isActive>1</isActive>
</Status>
<Status diffgr:id="Status12" msdata:rowOrder="11">
<id>28</id>
<name>Review2</name>
<categoryId>3</categoryId>
<assignrule>P</assignrule>
<ismoveAssign>0</ismoveAssign>
<isActive>1</isActive>
</Status>
<Status diffgr:id="Status12" msdata:rowOrder="11">
<id>28</id>
<name>Review3</name>
<categoryId>3</categoryId>
<assignrule>P</assignrule>
<ismoveAssign>0</ismoveAssign>
<isActive>1</isActive>
</Status>
</NewDataSet>
</diffgr:diffgram>
2) You apply XQuery:
<Result>
{
for $x in //Status
return <name> string {data($x/name/text())} </name>
}
</Result>
3) And get:
<?xml version="1.0" encoding="UTF-8"?> <Result> <name> string Review1</name> <name> string Review2</name> <name> string Review3</name> </Result>
?
Let me know,
Cheers,
Rupert
<diffgr:diffgram xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<NewDataSet xmlns="">
<Status diffgr:id="Status1" msdata:rowOrder="11">
<id>28</id>
<name>Review1</name>
<categoryId>3</categoryId>
<assignrule>P</assignrule>
<ismoveAssign>0</ismoveAssign>
<isActive>1</isActive>
</Status>
<Status diffgr:id="Status2" msdata:rowOrder="11">
<id>28</id>
<name>Review2</name>
<categoryId>3</categoryId>
<assignrule>P</assignrule>
<ismoveAssign>0</ismoveAssign>
<isActive>1</isActive>
</Status>
<Status diffgr:id="Status3" msdata:rowOrder="11">
<id>28</id>
<name>Review3</name>
<categoryId>3</categoryId>
<assignrule>P</assignrule>
<ismoveAssign>0</ismoveAssign>
<isActive>1</isActive>
</Status>
</NewDataSet>
</diffgr:diffgram>
The StatusID also keeps changing here..
- rupert_anderson10 years agoValued Contributor
OK, so it does, do you exepect to see the id in the output, thats not outlined in the original post? If so, please provide a sample of exactly what you expect in terms of the resulting XML and then I might be able to help.
- nmrao10 years agoCommunity HeroIs there any relation between the id and name? What is the issue if id gets changed?
- Sphujidhwaj10 years agoContributor
Yes there is relation between ID and Name with the varying input in the Request XML these IDs and Names change accordingly.
I get a response as shown in the previous post.
Please find the screenshot attached in the earlier post. I get statuses which are nearly 400-500 which I need to assert. Is XQuery Match Configuration assertion good to use ?
- rupert_anderson10 years agoValued Contributor
Ok, so aside from the ID and Name changing per status element, are you actually trying to ask whether using an XQuery Assertion is a good choice to confirm that your response is correct?
If so, do you have a list of statuses and names that you would like to check for? Can you say exactly how you would like to check the resonse?
As an alternative, if you had a list of expected values to check against you could use a Script Assertion to iterate over the status elements and lookup the expected values from the list to do a comparision...
From your first post, it seemed like you just wanted to fix your XQuery script to extract <result>...</result> elements which you were going to compare to some expected values.