Hello Monks, I have some XML such as this, where the linktext element contains a combination of text and other elements:
<citreference id="mycite"> <linktext><keyword conref="ds"/> support for IPv6 addresses</linktext> </citreference>
I can capture this with XML::Twig by creating an array, and referencing it thusly, where $citref is my handler:
my(@children) = $citref->first_child('linktext')->children; $linktext{$citref->att('id')} = \@children;
Simple enough. The question I'm having is how to extract that into another element elsewhere? I couldn't find that in the documentation. Something like:
my($h) = $linktext{'xxx'}; # the xxx is the appropriate id for the has +h $newcontext->set_text(\@$h); # $newcontext is 'xref' in this case
That doesn't work right, but I'm getting something in the output:
<xref>ARRAY(0x4128670)</xref>I suspect the $e->set_text() function only applies to text (not elements) and I suspect if there's more than one text segment each will clobber the previous. Hence I'm cautious about iterating through the array.
Any tips on how to do this? Thank you.
In reply to XML::Twig - setting text and elements by slugger415
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |