in reply to XML::Twig usage incomprehension

You get the attributes with
$job->{'att'}->{'attributename'}
Have you ever tried perldoc XML::Twig?

s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
+.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e

Replies are listed 'Best First'.
Re^2: XML::Twig usage incomprehension
by mirod (Canon) on Mar 31, 2006 at 21:12 UTC

    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.

      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; }
      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.