Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8888809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:06:53+00:00 2026-06-14T22:06:53+00:00

I have written a REST service hitting a MySQL database. This service will soon

  • 0

I have written a REST service hitting a MySQL database. This service will soon be ported to a newer system using a MongoDB database. Later, it may be ported to another system using Oracle.

Why we are porting so much is unimportant.

There are several nested tags in the resulting XML with the same name, a common case:

Sample:

<root>
    <level1>
        <name>Karl</name>
    </level1>
    <level1>
        <name>Anton</name>
    </level1>
    <level1>
        <name>Friedrich</name>
    </level1>
    <level1>
        <name>Anton</name>
    </level1>

</root>

I have been using SoapUI to test the results between systems, to make sure that the queries and such are still working properly. Integration testing and all that.

So the question is, is there a way in XPath or XQuery to test that “Karl” appears once in the results, “Anton” appears twice, and “Friedrich” appears once? I would normally just test //root/level1[1]/name == “Karl”, etc., but I can’t rely on consistent ordering between the systems. Is there a way to test unordered results? Or perhaps is there a way to verify that the right number of level1 elements have the same name value within? I know there’s a count function, but I’m unsure how elaborately it can be used.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:06:54+00:00Added an answer on June 14, 2026 at 10:06 pm

    So the question is, is there a way in XPath or XQuery to test that
    “Karl” appears once in the results, “Anton” appears twice, and
    “Friedrich” appears once?

    Use:

    count(/*/level1/name[.='Karl']) = 1
    
    count(/*/level1/name[.='Anton']) = 2
    
    count(/*/level1/name[.='Friedrich']) = 1
    

    These are three separate XPath expressions, each of which must evaluate to true().

    Alternatively, you can combine them into a single XPath expression that can be evaluated just once:

        count(/*/level1/name[.='Karl']) = 1
    and
        count(/*/level1/name[.='Anton']) = 2
    and
        count(/*/level1/name[.='Friedrich']) = 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written REST web service in netbean IDE using jersey framework and java.
I have written a REST service with windows azure using the WCF Rest Service
I have written a REST web service with Jersey Server (that totally rocks !).
I am new to web services. I have written a rest web service which
I have written a WCF service with the REST template that has the defaultOutgoingResponseFormat
I have written a service that I would like expose both via rest and
I have REST Web service written in Java. Now I want to disable Web
i have written a stand alone WCF REST service in 4.0 under Studio 2010
I have a web service written in C# using SOAP. A client has requested
I have a generic REST service layer written to Java modules which can be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.