CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



ralperl
New User

Aug 14, 2011, 9:42 AM

Post #1 of 2 (2158 views)
Regexp to parse XML input returned Can't Post

HI,



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

<Service>YldCurves</Service>
<Host>lnqds1a</Host>
<Admin>21521</Admin>


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



Thanks,

Ral


FishMonger
Veteran / Moderator

Aug 14, 2011, 10:11 AM

Post #2 of 2 (2156 views)
Re: [ralperl] Regexp to parse XML input returned [In reply to] Can't Post

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

XML::Simple http://search.cpan.org/~grantm/XML-Simple-2.18/lib/XML/Simple.pm
or
XML::Parser http://search.cpan.org/~toddr/XML-Parser-2.41/Parser.pm
or
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

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives