in reply to Help extracting text from XML data

The module that will do you for today, tomorrow and many days after that for processing XML is XML::Twig. Consider:

use warnings; use strict; use XML::Twig; my $xml = <<XML; <?xml version="1.0" encoding="utf-8"?> <string xmlns="test.test.com/site/TST/">someresult</string> XML my $twig = XML::Twig->new (twig_roots => {string => \&pullString}); $twig->parse ($xml); sub pullString { my ($t, $elt) = @_; print $elt->text (), "\n" }

Prints:

someresult

Perl reduces RSI - it saves typing

Replies are listed 'Best First'.
Re^2: Help extracting text from XML data
by perlnewb123 (Sexton) on Oct 20, 2008 at 20:56 UTC
    Thank you everyone! I had a regex that was parsing it down to >someresult<, but that was as far as I could get. This is much better!