use Test::More tests => 1;
my $in = '<seg><foo mid="0" mtype="seg"><g id="1">Need to export this
my $want = '<g id="1">Need to export this text</g>';
my $xml = XML::LibXML->load_xml (string => $in);
my $have = $xml->getElementsByTagName ('g')->shift->toString;
is ($have, $want);
Thank you for your help. I gave it a try and it works when it has tags. However, there are cases where the extracted text doesn't contain tags (i.e. <seg><foo mid="0" mtype="seg">Need to export this text</foo></seg>.
i used this one my $mrktext = $mrk->getElementsByTagName ('*')->shift->toString;