Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl SAX - reading attributes

Status
Not open for further replies.

Zippeh

Programmer
Sep 24, 2002
56
GB
Hi there,

Trying to use SAX now to process my XML Document, but having some difficulties reading the attributes of an element. What I have is this:

Code:
sub start_element {
  my ($self, $data) = @_;
  if ($data->{Name} eq 'batch') {
	print Dumper($data);
    my $batch_company = $data->{Attributes->"batch_company"->{Value};
  }
}

I know this is wrong, but I'm trying to read the attribute "batch_company" which occurs in the "batch" element. How can I go about this?

TIA
 
Have you tried this;

my $batch_company=$data{'batch_company'};

--Paul

cigless ...
 
I found the answer on another site after further research. This works:

Code:
    $batch_company = $data->{Attributes}->{"{}batch_company"}->{Value};
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top