Is not $section what you want as a starting point?
sub uml_class { my ( $twig, $section ) = @_; $section->print (); }
Prints:
<UML:Class name="EARootClass" xmi.id="EAID_..."/><UML:Class name="Data +Type" xmi.id="EAID..."><UML:Classifier.feature xmi.id="EAID..."> <!-- I want to pull out the following UML:Attribute blocks --> <UML:Attribute name="dataTypeId"></UML +:Attribute><UML:Attribute name="name"></UML:Attribute></UML:Classifie +r.feature></UML:Class>
Update:
Note the "Processing just parts of an XML document" section in the XML::Twig documentation that describes twig_roots and in particular the line my( $t, $elt)= @_; in the sample code in that section.
Update:
and to reparse the sub-element:
sub uml_class { my ( $twig, $section ) = @_; my $xml = $section->sprint (); my $subTwig = XML::Twig->new ( twig_roots => { 'uml:attribute' => +\¨_attr}); $subTwig->parse ($xml); } sub uml_attr { my ($twig, $elt) = @_; $elt->print (); print "\n"; }
Prints:
<uml:attribute name="datatypeid"></uml:attribute> <uml:attribute name="name"></uml:attribute>
In reply to Re: Pulling out sections of an XMI file with XML::Twig
by GrandFather
in thread Pulling out sections of an XMI file with XML::Twig
by bobf
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |