in reply to Parsing an xml file
Again - this code makes many assumptions on the syntax AND formatting of the incoming "XML".use strict; use warnings; use Getopt::Long; use File::Glob (); my %options=(); GetOptions (\%options,'loc=s'); my $contents_xml = glob(($options{loc} . '\\contents.xml')); open my $f, "<", $contents_xml or die "Cannot open $contents_xml:$!"; while (<$f>){ m/=\s*"([^"]+)"[^\/]*?>([^<]+)/ and print "$1 $2\n"; } close $f;
"XML is like violence: if it doesn't solve your problem, use more."
|
|---|