Please help me with making script

In this example i like to parse birthday and sexe


birthday
6 apr 1961


sexe
Male

These ruby script will not work, please who can help me?

options[:birthday] = find(:xpath, “.//span[contains(@id,
“lblbirthday”)]”).text
options[:sexe] = find(:xpath, “.//span[contains(@id,
“lblsexe”)]”).text

On Tue, Sep 11, 2012 at 5:16 PM, Charmaine W.
[email protected] wrote:

</div>

These ruby script will not work, please who can help me?

options[:birthday] = find(:xpath, “.//span[contains(@id,
"lblbirthday")]”).text
options[:sexe] = find(:xpath, “.//span[contains(@id,
"lblsexe")]”).text

Are you using Nokogiri or Hpricot? What happens when you try it?

try modifying your XPath to use the following (worked for me using
nokogiri)

“//*[@id=‘lblbirthday’]”

and

“//*[@id=‘lblsexe’]”

On Tue, Sep 11, 2012 at 3:16 PM, Charmaine W.

Jason Gleeson wrote in post #1075547:

try modifying your XPath to use the following (worked for me using
nokogiri)

“//*[@id=‘lblbirthday’]”

and

“//*[@id=‘lblsexe’]”

On Tue, Sep 11, 2012 at 3:16 PM, Charmaine W.

Thanx, but its not working, any other suggestion?
I don’t know if I work with nokogiri, it’s a ruby (1.9.3) script

Eric C. wrote in post #1075546:

On Tue, Sep 11, 2012 at 5:16 PM, Charmaine W.
[email protected] wrote:

</div>

These ruby script will not work, please who can help me?

options[:birthday] = find(:xpath, “.//span[contains(@id,
"lblbirthday")]”).text
options[:sexe] = find(:xpath, “.//span[contains(@id,
"lblsexe")]”).text

Are you using Nokogiri or Hpricot? What happens when you try it?

Don’t know, this is made in Ruby 1.9.3.

On 12 September 2012 14:22, Charmaine W. [email protected]
wrote:

I don’t know if I work with nokogiri, it’s a ruby (1.9.3) script

Is there a line like ‘require “nokogiri”’ somewhere near the top of
the code or perhaps something like ‘require “hpricot”’

If the script is not too long then maybe you should post that

See attached script,

Output must be:

Name : A.Johnson
number : 163245771
birthday:15 sep 1944
sexe : Male
adres :345 Orson street
zipcode:RG 3425
city: Honeyfield

Packetname 1: Care
Insurancenumber 1:3767801
Startdate 1:01 jan 2011
Enddate 1:
Status 1:
NMAUN 1: 542

Packetname 2: ExtraCare
Insurancenumber 2:3767801
Startdate 2:01 jan 2011
Enddate 2:
Status 2:
NMAUN 2: 542

Packetname 3: SpecialCare
Insurancenumber 3:3767801
Startdate 3:01 jan 2011
Enddate 3:
Status 3:
NMAUN 3: 542

I see your problem.

You dont know the difference between a ruby script and an XML file.

Although the data is obviously useful without the script we cannot
tell what you are doing wrong and help you.

Unless you are expecting us to write this for you, my rates are
reasonable but I require cash upfront from clients who have no clue

Peter H. wrote in post #1075778:

I see your problem.

You dont know the difference between a ruby script and an XML file.

Although the data is obviously useful without the script we cannot
tell what you are doing wrong and help you.

Unless you are expecting us to write this for you, my rates are
reasonable but I require cash upfront from clients who have no clue

You’re right, I’m not familiar with programming any language. But I like
to solve problems.

I paid already a lot of money for making this script, but unfortunaly
the site has changed since a week, and is now made with (don’t ask me)
div’s , so the sricpt isn’t running anymore. Because I’m not coming out
an egg, I changed some lines with ‘lbl’ and these will run now. But the
‘name’ who isn’t a lbl, I don’t know to fix. Look here:

NameA Johnson

Its in a header, so can anyone tell me what de script has to be to parse
it?

Thanks a lot, Charmaine

2012/9/12 Charmaine W. [email protected]

</div>


Posted via http://www.ruby-forum.com/.

  1. Nokogiri doesn’t have method find, maybe he is using Capybara.
    If so try to find with css since it’s simpler:
    options[:birthday] = find(“span#lblbirthday”).text
    options[:sexe] = find(“span#lblsexe”).text

In any case Capybara converts css to xpath when searching.

  1. You could do it with Nokogiri too. Here is complete example:
    require ‘nokogiri’

html = “


birthday
6 apr 1961


sexe
Male

doc = Nokogiri::HTML(html)
options = {}
options[:birthday] = doc.at_css(‘span#lblbirthday’).content
options[:sexe] = doc.at_css(‘span#lblsexe’).content

options.each { |key, value| puts “#{key}: #{value}” }

It outputs:
birthday: 6 apr 1961
sexe: Male

So Peter, whats is your emailadres so I can give you my wishes and you
can give your best offer, with kind regards, Charmaine

You can hire me on elance if you want :slight_smile:

2012/9/13 Charmaine W. [email protected]