Forum Discussion

alejandrovargas's avatar
alejandrovargas
Occasional Contributor
9 years ago

Xquery assertion - search a variable inside a node

Hi,

 

Using XQuery assertion we need to print the text of a variable that is inisde a node. In the file attached appears the value that I need, and the wrong answer with extra information that we do not need.

 

XQuery Expression

<Result>
{
for $x in //baggageEstimationFees/baggageConditions/selectableBaggageDescriptor
return
<element>
<pieces>{$x/baggageDescriptor[@pieces]}</pieces>
<price>{$x/price/text()}</price>
</element>
}
</Result>

 

Our result expected: 

<Result>
<element>
<baggageDescriptor pieces="0"/>
</pieces>
<price>0.00</price>
</element>
<element>
<pieces>
<baggageDescriptor pieces="1"/></pieces>
<price>37.50</price>
</element>
</Result>

 

Or: 

<Result>
<element>
<pieces>0</pieces>
<price>0.00</price>
</element>
<element>
<pieces>
<pieces>1</pieces>
<price>37.50</price>
</element>
</Result>

 

  • nmrao's avatar
    nmrao
    Champion Level 3
    Would you like to show the response that you were working on?
    • alejandrovargas's avatar
      alejandrovargas
      Occasional Contributor

      Sorry to answer late, I took some days for the eastern week.

       

      I need an output similar to the input is right, I need to confirm values that comes from the database that are chaning. I tried to use XQuery and not Xpath to use less amount of assertions.

       

      I do not if this is possible with XQuery, or I should use Xpath.