in reply to Re: XML::Twig usage incomprehension
in thread XML::Twig usage incomprehension

Well, $job->{'att'}->{'attributename'} actually breaks the encapsulation. The proper way would be $job->att( 'attributename'). Which of course begs the question: Have you ever tried perldoc XML::Twig? ;--) (or looking at the XML::Twig Quick Reference?)

I can't really blame you though, I tend to do the same thing: when I start working with a module, I use the debugger to figure out its implementation, and often "forget" to read the API.

Replies are listed 'Best First'.
Re^3: XML::Twig usage incomprehension
by Skeeve (Parson) on Apr 03, 2006 at 06:39 UTC
    I read it a thousand times or more. Not from top to bottom, but using /searchword and then reading. I actually never read anything about $job->att('attributename') and was always asking myself, why I had to use a hash here. I never had the idea to search further. Thanks for pointing me at it!

    s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
    +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e
      I tried this method but still have no results :(
      
      Though,I'm sure that I should get some ....
      Is there something wrong with my code?
      
      
      use strict; use XML::Twig; my $t= new XML::Twig(); my $root = $t->root; $t->parsefile( 'T:\\BI\\Jerome\\xml\\tree.xml'); exit; sub job { my ($t, $root)= @_; my %job; $job{Attr_name}= $root->{'att'}->{'Name'}; $job{Attr_value}= $root->{'att'}->{'Value'}; print "$job{Attr_name}: $job{Attr_value}\n"; $root->delete; }
        There are no attributes called 'Name' or 'Value' in your Element named 'Job'.
        <Job Identifier="adresses" DateModified="2006-03-28" TimeModified=" +17.15.15">

        s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
        +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e
Re^3: XML::Twig usage incomprehension
by Anonymous Monk on Apr 02, 2006 at 13:34 UTC
    OK, thanks for the clue!

    I can't swear I already used this method but it seems familiar to me....

    Though, I know the perloc -f command but the twig one seems too much complex for me...nobody's perfect ;)

    The twig web site got some examples too, I tried to adapt these examples to my needs but with no success.

    I'll try this code portion tommorrow and will keep you informed about the results.

    Regards.

    Jerome.