cancel
Showing results for 
Search instead for 
Did you mean: 

How to verify the presence of an xml element(node) in an xml?

SOLVED
Highlighted
Contributor

How to verify the presence of an xml element(node) in an xml?

sample xml: 

<ApiRootContext xmlns="http://schemas.datacontract.org/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
   <ApiHeader xmlns:a="http://schemas.datacontract.org/20/0/dbfasdjk.Context">
      <a:Duration>2218.3778</a:Duration>
      <a:EndTime>2017-09-15T10:13:26.4970511-04:00</a:EndTime>
      <a:RequestGuid>c0594d5b-4f15-4fc0-9efc-f574492796f8</a:RequestGuid>
      <a:RequestStatus>Eligibility</a:RequestStatus>
      <a:StartTime>2017-09-15T10:13:24.2782836-04:00</a:StartTime>
   </ApiHeader>
   <QuoteContext xmlns:a="http://schemas.datacontract.sfnadkfnjksfl.Api.Context">
      <a:HomeOwners>
         <a:DisplayOnlyData/>
         <a:PolicyData/>
         <a:QuoteData>
            <a:AdditionalInterestList xmlns:b="http://schemas.dadvfladfnkjlad.Context"/>
            <a:approxFairMarketValue>482678.00</a:approxFairMarketValue>
            <a:dateOfBirth>1979-04-20T00:00:00</a:dateOfBirth>
            <a:effectiveDateOfPolicy>2017-09-23T00:00:00</a:effectiveDateOfPolicy>
            <a:firstName>Wendi</a:firstName>
            <a:yearOfConstruction>1978</a:yearOfConstruction>
         </a:QuoteData>
         <a:QuoteHeader>
            <a:Channel>Direct_Web</a:Channel>
            <a:CompleteQuoteFlag>false</a:CompleteQuoteFlag>
            <a:QuoteStatus>dafvnadk</a:QuoteStatus>
            <a:SessionHash>adfnadjfkajdvnkdn</a:SessionHash>
         </a:QuoteHeader>
         <a:QuoteOffers/>
      </a:HomeOwners>
   </QuoteContext>
</ApiRootContext>

 

How do i verify if "approxFairMarketValue" node is present or not using groovy?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super Contributor

Re: How to verify the presence of an xml element(node) in an xml?

XPath Match assertion

exists(//*:approxFairMarketValue)

 

or if you need to use script assertion

https://www.soapui.org/functional-testing/validating-messages/using-script-assertions.html

View solution in original post

3 REPLIES 3
Highlighted
Super Contributor

Re: How to verify the presence of an xml element(node) in an xml?

XPath Match assertion

exists(//*:approxFairMarketValue)

 

or if you need to use script assertion

https://www.soapui.org/functional-testing/validating-messages/using-script-assertions.html

View solution in original post

Highlighted
Community Hero

Re: How to verify the presence of an xml element(node) in an xml?

Highlighted
Contributor

Re: How to verify the presence of an xml element(node) in an xml?

Thanks @nmrao and @PaulMS for the solution. I am in a different timezone which is why there is a delay in the reply.

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors