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 8880747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:13:05+00:00 2026-06-14T20:13:05+00:00

i am totally new to xquery and I am having problem getting the right

  • 0

i am totally new to xquery and I am having problem getting the right stuff out of my xml codes.

Here is a sample of my xml file that i am working on:

<root>
  <name id = "a">
    <first> Mary </first>
    <last> Britton </last>
    <company> ABC </company>
    <phone> 203-942-0485 </phone>
  </name>

  <paper pid = "b">
    <pname> Hello </pname>
    <author> a </author>
  </paper>

  <publish>
     <pbid> b </pbid>
     <location>
         <place> new york </place>
         <sales> 100 </sales>
     </location>
     <location>
         <place> los angeles </place>
         <sales> 200 </sales>
     </location>
  </publish>

I am trying to get the author’s company and phone number for those who has published in new york with at least 50 sales.

Right now, I can only get the location information, not even the publish information. Any hint or help on how to think through this problem? Thanks in advance!

  • 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-14T20:13:06+00:00Added an answer on June 14, 2026 at 8:13 pm

    This pure XPath 2.0 expression:

    /*/name[for $auid in @id,
                      $p in /*/paper[author eq $auid],
                      $pid in $p/@pid
                   return
                      sum(/*/publish[pbid[1] eq $pid]
                                  /location[place eq 'new york']
                                        /sales
                         )
                      ge 50
               ]
                /(company | phone)
    

    When evaluated against the following XML document (the provided one with extraneous white-space eliminated, in order to avoid having to construct a unnecessarily complicated XPath expression that would use normalize-space() almost everywhere):

    <root>
        <name id = "a">
            <first> Mary </first>
            <last> Britton </last>
            <company> ABC </company>
            <phone> 203-942-0485 </phone>
        </name>
        <paper pid = "b">
            <pname> Hello </pname>
            <author>a</author>
        </paper>
        <publish>
            <pbid>b</pbid>
            <location>
                <place>new york</place>
                <sales> 100 </sales>
            </location>
            <location>
                <place> los angeles </place>
                <sales> 200 </sales>
            </location>
        </publish>
    </root>
    

    produces the wanted, correct result:

    <company> ABC </company>
    <phone> 203-942-0485 </phone>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Totally new to Capistrano. I have a local git repository that I want to
I'm totally new to AWS. I managed to have an instance that runs PHPMyAdmin.
I'm totally new in OpenCV so hopefully that's not a too stupid question. As
I´m totally new to Powershell and wanted to write a script that deletes all
I'm totally new to this web development stuff. So I see things like localhost
I'm totally new to Scala. Here I have tried to assign a empty array
im totally new to rails. here my question: i made an app with articles
Totally new to custom control creation in Silverlight. I'm wanting a custom control that
Totally new to xpath. I have xml: <Values> <Value Value=a CustomAtr=1 /> <Value Value=b
im totally new at stack overflow, I usually just research stuff myself but I

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.