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

  • Home
  • SEARCH
  • 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 6046093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:11:55+00:00 2026-05-23T07:11:55+00:00

best shown by a simplified example: <?xml version=1.0 encoding=utf-8?> <root> <A name=wrong></A> <B>not this</B>

  • 0

best shown by a simplified example:

<?xml version="1.0" encoding="utf-8"?>
<root>
    <A name="wrong"></A>
    <B>not this</B>
    <A name="right">
      <subA></subA>
    </A>
    <B>yes, this</B>  <!-- I want only this one -->
    <A name="right">
      <subA></subA>
    </A>
    <C>dont want this</C>
    <B>not this either</B>  <!-- not immediately following -->
</root>

I want all <B> nodes that are immediately following an <A> node with name attribute equals "right".

What I tried:

//A[@name="right"]/following-sibling::*[1]

which selects any node immediately following the “right” <A> (i.e. including <C>). I don’t see how to make it only <B>. This didn’t work:

//A[@name="right"]/following-sibling::*[1 and B]

This one:

//A[@name="right"]/following-sibling::B[1]

would select the first <B> after the “right” <A>, but not necessarily the immediately following one.

  • 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-05-23T07:11:56+00:00Added an answer on May 23, 2026 at 7:11 am

    You were nearly there:

    //A[@name='right']/following-sibling::*[position()=1 and self::B]
    

    gives exactly one node on your sample.

    To refer to the element name in a condition, you need self. Simply [B] would mean an element with text exactly equal to B.

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

Sidebar

Related Questions

This is probably best shown with an example. I have an enum with attributes:
I have the following situation I think would be best to show in sample
What's the best way to use QT4's QItemDelegate to show thumbnails for images in
In ASP.NET what's the best way to do the following: Show certain controls based
Bascially I want to know the best way to hide/show an ASP.NET control from
In Django 1.0, what is the best way to catch and show an error
Best recommendations for accessing and manipulation of sqlite databases from JavaScript.
How best to make the selected date of an ASP.NET Calendar control available to
For best performance, is it better to use a virtual IDE HDD or virtual
As best-behaved as I try to be about keeping my unit tests disconnected from

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.