*click* ...a lightbulb turns on...
Thank you for the example code - that made all the difference! I didn't realize that $section was actually an XML::Twig::Elt object. Using your example as a starting point, I was able to get what I needed.
At first I thought I needed to parse the XML chunks into a data structure (such as that returned by XML::Simple), which I accomplished using
but I soon realized that was overkill for what I really needed - the value of the attributes for the class (etc) tags. The $elt->att( $attribute ) method did the trick. An example of the class handler from my working code is below.my $struct = $section->simplify( forcearray => 1 );
sub uml_class { my ( $twig, $section ) = @_; print "data for class:\n"; print " name = ", $section->att( 'name' ), "\n"; print " xmi.id = ", $section->att( 'xmi.id' ), "\n"; my $subTwig = XML::Twig->new( twig_roots => { 'UML:Attribute' => \¨_attr } +); # $subTwig->parse( $xml ); # original code (typo) $subTwig->parse( $section->sprint() ); }
Thanks again! I knew I was making it too hard. :-)
Update: corrected typo in the example code
In reply to Re^2: Pulling out sections of an XMI file with XML::Twig
by bobf
in thread Pulling out sections of an XMI file with XML::Twig
by bobf
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |