[Rake] Parse XML File, recursive function

Hi everybody,

I’m taking time to post message here because, i have a problem which
making
me crazy.

I’m trying to design a Rake Task which parse XML file and create some
drill
down on products categories.

To begin my explanation, some file and function.

First, my XML file

> > Mini Z > > 420 > > > >

Pastie link : http://pastie.org/459107

Second, my main Rake Task

Affichage d un message

  :name => 'Catégories',


      p message
      taxon_menu_id = taxon_menu[index_menu].id

        # Recursive sub menu
        recursive_sous_menu_creation(categorie, message, taxon_menu_id,

root)

    end

  end
end

Pastie link : http://pastie.org/459108

Third, Recursive function “recursive_sous_menu_creation”

def recursive_sous_menu_creation(xml, message, taxon_mother_id, root)

      # Apres creation du tableau des pages
        recursive_sous_menu_creation(sous_sous_menu, message,

taxon_sous_menu_mother.id, root)
end
end

  end

end

Pastie link : http://pastie.org/459110

And, the end, the result

“#############################”

“15933:FC2000:Flycam one 2 caméra version de luxe:56.97:21”
“16494:870010712:E10 drift mazda rx7 peinte rtr:148.76:2”
"
“18366:31315T1:Racing kart birel r31-se 1/5 ready set:251.25:1”
“17965:8700100647:Savage flux rtr:826.26:1”
“18455:G20010R:Monster truck complet:833:1”
“18456:G60020R:Baja buggy 26cm3 rtr:831.25:1”

Observation
First, my concatenation message is wrong, because, my rake task create
sub
categories (Dnano, Mini Z / Mini Z Drift) on the categories
“Intermédiaire”,
but, it doing the same on the root of “Voiture”

All help is greathy appreciate.

Best regards,

Mickaël.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs