in reply to & and XML::Simple

Hello Jazz-jj and welcome to themonastery and to the wonderful world of Perl,

> I'm using XML::Simple to parse some xml..

This is the first error: see XML::Simple needs to go! and the very beginning of the module iself to know why.

Different valid options are on CPAN to safely parse XML: i choosed XML::Twig and I'm happy with it (but still unhappy with XML in itself!)

XML::Twig has a lot of features and tutorials on the author website.

Next times give us a short sample of your data to make it easier to help you.

I'd go with something like

use strict; use warnings; use XML::Twig; my $t= XML::Twig->new( pretty_print => 'indented', twig_handlers => { # $_[1] is the elemen +t 'results_link' => sub{ $_[1]->print;} }); my $data =<<EOXML; <?xml version="1.0"?> <!DOCTYPE stats SYSTEM "stats.dtd"> <results_link>https://myserver.com/app/search?q=%7Cloadjob%20scheduler +_amJ1bGxvdWdoQGRldi1hbWVyaWNhZmlyc3QuY29t_at_1496880600_682%20%7C%20h +ead%2020%20%7C%20tail%201&amp;earliest=0&amp;latest=now</results_link +> EOXML $t->parse( $data);

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: &amp; and XML::Simple
by Jazz-jj (Novice) on Jun 08, 2017 at 14:26 UTC
    Cool. Thanks guys. This is version 1 of this integration script, so, if other modules work better for moving XML from one system to another, I'll definitely give them a try. Thanks! Jazz
Re^2: &amp; and XML::Simple
by locked_user sundialsvc4 (Abbot) on Jun 08, 2017 at 20:52 UTC

    And for completeness, XML::LibXML is probably the other best choice (IMHO) alongside Twig.   This package uses the same libxml2 binary library that is very much an industry standard for handling XML.   You often wind up processing another program’s XML file outputs using the same underlying library that it used to build them.   (Whether or not they used Perl to drive it.)