Ockie has asked for the wisdom of the Perl Monks concerning the following question:
how should I pass my current node to the subroutine so I can access its child nodes directly from the routine?foreach $day ($doc->findnodes('/my/current/path')){ @atts = $day -> getAttributes(); foreach $at (@atts) { $na = $at -> getName(); $va = $at -> getValue(); if ($va eq "today"){ #------ my repeated code here ----- foreach $thing ($day->findnodes('child_nodes_im_looking_for')) +{ #----- do a lot of stuff } } if ($va eq "tomorrow"){ #same repeated code } if ($va eq "some_other_day"){ #same repeated code.... again } #for other days... do nothing }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Working with child nodes in subroutine (XML::LibXML)
by Eily (Monsignor) on Nov 04, 2014 at 13:46 UTC | |
by Ockie (Initiate) on Nov 04, 2014 at 15:21 UTC | |
|
Re: Working with child nodes in subroutine (XML::LibXML)
by perlron (Pilgrim) on Nov 04, 2014 at 15:04 UTC | |
by Ockie (Initiate) on Nov 04, 2014 at 18:46 UTC |