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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:26:30+00:00 2026-06-02T16:26:30+00:00

Using ruby 1.9.3 and Nokogiri (latest): Given (no, I did not come up with

  • 0

Using ruby 1.9.3 and Nokogiri (latest):

Given (no, I did not come up with this):

<root>
<subelement>
    <key>
          <var name="id">50</var>
          <var name="secondaryid">0</var>
     </key>
</subelement>
<subelement>
   <key>
          <var name="id">50</var>
          <var name="secondaryid">1</var>
   </key>
</subelement>
</root>

Return the parent element (<key>) which has a var element with name property equal to “id” and a value equal to 50 AND a var element with name property equal to “secondaryid” and a value equal to 0. Do not return the node with id=50 and secondaryid=1.

Obviously it’s going to be built off something along the lines of:

@doc.xpath(“//var[@name=’id’ and text()=50]”)

but I can’t figure out how to add another predicate that will match the name = “secondaryid” element too.

  • 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-02T16:26:31+00:00Added an answer on June 2, 2026 at 4:26 pm

    Not tested with Ruby, but this should do the trick.

    //key[var[@name='id'] = '50'][var[@name='secondaryid'] = '0']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This Ruby code using Nokogiri doc.xpath(//tbody).remove removes the children of the <tbody> (as well
If I want to parse a HTML block using Nokogiri in Ruby like this:
I have trouble parsing a HTML table using Nokogiri and Ruby. My HTML table
Using Nokogiri and Ruby. I have a page to parse with div id's like:
I'm using Ruby, with the Nokogiri module, and i want to get the content
I am using nokogiri and ruby to script some deployment scripts and I need
I am using ROXML with Nokogiri for XML/Ruby Object Mapping in Rails 3 and
I'm using Ruby (and Nokogiri in case that is helpful) to encode some documents.
what is the best method using ruby/mechanize/nokogiri to go/click through all pages in case
Given (no comments about the XML naming necessary): <config> <unit> <var name='model'>3100</var> <var name='type'>production</var>

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.