in reply to Re: Pulling out sections of an XMI file with XML::Twig
in thread Pulling out sections of an XMI file with XML::Twig
*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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Pulling out sections of an XMI file with XML::Twig
by mirod (Canon) on Sep 28, 2006 at 09:42 UTC | |
by bobf (Monsignor) on Sep 28, 2006 at 16:00 UTC | |
by mirod (Canon) on Sep 28, 2006 at 16:52 UTC | |
by bobf (Monsignor) on Sep 28, 2006 at 17:32 UTC |