Home: Perl Programming Help: Regular Expressions:
Regexp to parse XML input returned

New User

Aug 14, 2011, 9:42 AM

Views: 5184
Regexp to parse XML input returned


Am fairly new to using regexp - and am trying to capture and parse some input from XML received in simialr format to following


I want to only extract the actual value for both HOst and Port - ignoring the tags - have tried various options using regexp most basic being m/Host(.*?)Host/

Is this approach possible? Or woudl I be better outputting to a file - then using other options to capture value such as grep etc?

Any feedback much appreciated



Veteran / Moderator

Aug 14, 2011, 10:11 AM

Views: 5182
Re: [ralperl] Regexp to parse XML input returned

Use one of Perl's XML parsers, such as:

XML::Simple http://search.cpan.org/~grantm/XML-Simple-2.18/lib/XML/Simple.pm
XML::Parser http://search.cpan.org/~toddr/XML-Parser-2.41/Parser.pm
XML::Twig http://search.cpan.org/~mirod/XML-Twig-3.38/Twig.pm

A more complete list can be found here. http://search.cpan.org/search?query=XML&mode=all