penantes has asked for the wisdom of the Perl Monks concerning the following question:

Wise monks,
Im trying to to parse the server.xml of a tomcat config so I can collect its configuration, I imagine the best way is to use XML::Parse. My problem is I'm not understanding the explanation... Can someone give and example please?
Best Regards,

janitored by ybiC: Retitle from less-than-descriptive and site-search-hindering-one-word "Tomcat"

Replies are listed 'Best First'.
Re: parse Tomcat XML configuration files
by borisz (Canon) on Mar 01, 2005 at 23:52 UTC
    Propably it is best to start wirth XML::Simple since it is easy to use.
    Anyway, I do not know XML::Parse Did you mean XML::Parser?
    There is a samples directory in the distribution with examples.
Re: parse Tomcat XML configuration files
by fauria (Deacon) on Mar 02, 2005 at 01:02 UTC
    You can use XML::Simple and change the hashref.

    use XML::Simple; use Data::Dumper; my $tomcat_file = '/var/tomcat4/conf/server.xml'; my $tomcat_conf = XMLin($tomcat_file) or die "Error reading config: $! +"; print Dumper $tomcat_conf; #Modify hashref $tomcat_conf my $modified_xml = XMLout($tomcat_conf, NoAttr => 1); print Dumper $modified_conf;
Re: parse Tomcat XML configuration files
by penantes (Acolyte) on Mar 02, 2005 at 09:26 UTC
    Yep, I meant Parser... ;)
    So, simple is my thing, I gonna try it perhaps its simpler for me to understand.

    Thank you borisz, fauria.
    Nuno A