in reply to Help with attributes and XML::Simple
See Simpler than XML::Simple for some reasons why you should not use XML::Simple and what to use instead.
As we do not know what do you need the data for, I can only guess in what format would you like them so just a tiny example. This code specifies that form each &lve;Vendor> you want the vendorUniqueKey as the key and the name as the value and then lets you execute some code to process this data once the </Vendors> tag is parsed. This style lets you process huge files without keeping everything in memory.
use strict; use XML::Rules; my $parser = XML::Rules->new( stripspaces => 7, rules => { Vendor => sub {return $_[1]->{vendorUniqueKey} => $_[1]->{name +}}, Vendors => sub { my ($tag, $vendors) = @_; print "We have " . scalar(keys %$vendors) . " vendors\n"; foreach (keys %$vendors) { print " $_ => $vendors->{$_}\n"; } return; }, ':default:' => '' } ); $parser->parse(\*DATA); __DATA__ <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Import format="3.0" fileId="54630000-3141-1404-4310-7F0000014030" fil +eCreationDateTime="2+012-07-23T06:04:31.415" catalogSource="TLCMz"> <Catalog> <Vendors> <Vendor name="Allen Systems" vendorUniqueKey="ALLENGRP"/> <Vendor name="Aonix North America" vendorUniqueKey="AONIX"/> <Vendor name="Beta Systems Software" vendorUniqueKey="BETASY +S"/> <Vendor name="BMC Software" vendorUniqueKey="BMC"/> </Vendors> </Catalog> </Import>
Jenda
Enoch was right!
Enjoy the last years of Rome.
|
|---|