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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:43:12+00:00 2026-06-14T13:43:12+00:00

I am fairly new to XPATH and need to return a value from multiple

  • 0

I am fairly new to XPATH and need to return a value from multiple XML objects when a certain node is equal to one of two values. The solution also needs to be namespace agnostic using local-name(). Given the following XML, I am looking to return all of the values of “B” where “A” is equal to either “4” or “5”.

<?xml version="1.0"?>
    <element>
        <A>3</A>
        <B>Value 1</B>
    </element>
    <element>
        <A>4</A>
        <B>Value 2</B>
    </element>
    <element>
        <A>5</A>
        <B>Value 3</B>
    </element>

I have tried many iterations of the following expression but cannot seem to get the syntax correct when I try to add the second value for “A”. I just can’t seem to figure out the correct syntax for an “or” expression. I have also considered the use of a union and couldn’t get that syntax correct either.

This works for when “A” equals a single value of “4” but how to I add the test for a value of “5” so that the result returns two values for “B” (“Value 2” and “Value 3”)?

//*[local-name()='element'][*[local-name()='A']='4']/*[local-name()='B']/text()

Thank you. Any help would be very much appreciated!

  • 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-14T13:43:13+00:00Added an answer on June 14, 2026 at 1:43 pm

    Try this:

    //*[local-name() = 'element']/*[local-name() = 'A' and (. = 4 or . = 5)]
        /../*[local-name() = 'B']
    

    This expression selects Value 2 and Value 3.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Fairly new to Linq to XML How does one remove xml node ( recursively
Ok, I am fairly new to working with xml, xpath etc. I am in
I am trying to parse some fairly flat HTML and group everything from one
Still fairly new to django and python... I've defined two forms as follows: class
Fairly new to Jquery here.... but one thing I have been told and being
I fairly new to regular expressions and need some help. I need to filter
fairly new to Objective-C and iOS development (coming from PHP) and I have a
Fairly new to Node.js Made an app that runs a server process and serve
Fairly new to iPhone dev. My app uses Core Data, and at one point
I'm still fairly new to T-SQL and SQL 2005. I need to import a

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.