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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:34:57+00:00 2026-06-09T11:34:57+00:00

Ok what I need is a little weird and goes as follows: Clues array

  • 0

Ok what I need is a little weird and goes as follows:

Clues array is created manually, Data array is created dynamically. An Xpath function takes our clues as input and maps the results to data to create a dynamic array

clues = Array.new

clues << 'Power supply type'    
clues << 'Slots'
clues << 'Software included'

selector = "//td[text()='%s']/following-sibling::td"

data = Array.new
data = clues.map do |clue| 
         xpath = selector % clue
         [clue, doc.at(xpath).text.strip]
       end

The code in the data array uses two inputs, clues and selector
every item at clues[index] goes into selector at %s to become

//td[text()='%s']/following-sibling::td  
//td[text()='Power supply type']/following-sibling::td
//td[text()='Slots']/following-sibling::td
//td[text()='Software included']/following-sibling::td

Xpath then goes off and grabs information from a webpage using our stored commands, all of this is then stored as elements in the array data as data[0]…data[3]

Data[2] looks like this, a big chunk of information

Symantec Norton Internet Security (60 days live update); Recovery partition (inc
luding possibility to recover system; applications and drivers separately); Opti
onal re-allocation of recovery partition;

I want to take each piece of software listed here and store it on its own e.g.

data[2]Symantec Norton Internet Security (60 days live update); 
data[3]Recovery partition (including possibility to recover system; 
data[4]Optional re-allocation of recovery partition;

So I assume I need to split data[2] somehow and add it back into the data array?

I am trying to isolate this particular index as I need it on multiple lines for my final output to spreadsheet

Final Desired output

enter image description here

  • 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-09T11:34:59+00:00Added an answer on June 9, 2026 at 11:34 am
    data = Array.new
    clues.each do |clue|
      xpath = selector % clue
      text = doc.at(xpath).text.strip
      if clue == 'Software included'
        values = text.scan(/.+?;/)
        values << text if values.empty? # text did not contain a semicolon
        data << [clue, values.shift.strip]
        values.each do |value|
          data << ['', value.strip]
        end
      else
        data << [clue, text]
      end
    end
    

    Output (indented to be more readable):

    [
      ["Power supply type", "400w"],
      ["Slots", "2"],
      ["Software included", "Symantec Norton Internet Security (60 days live update);"],
      ["", "Recovery partition (including possibility to recover system;"],
      ["", "applications and drivers separately);"],
      ["", "Optional re-allocation of recovery partition;"]
    ]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need little help regarding sharepoint solution set up in sharepoint. I created wspbuilder
The question is a little bit weird, but that's what I need ;) Usually,
I know this could sound a little weird, but I need to pass some
hey guys, a little weird question that doesn't actually need to be associated with
Ok, this may sound a little weird, but what I need to do is
I need little help for url rewriting in wordpress. basically what i need: mydomain.com/mysomewordpresspost
I would need little help here. I'm trying to get the git respository from
Need a little help with a SQL / ActiveRecord query. Let's say I have
Need a little help with my jquery here I want all my button with
I need a little help with an if statement in php. I'm trying to

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.