Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: XML package for parsing values in the opening tag.

by gjb (Vicar)
on Apr 14, 2004 at 14:04 UTC ( #345059=note: print w/ replies, xml ) Need Help??


in reply to XML package for parsing values in the opening tag.

XML::Simple will do the job nicely. The following code

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use XML::Simple; my $xml = XMLin('login.xml'); print Dumper($xml);
produces as output on your example:
$VAR1 = { 'LOGIN' => { 'firstName' => 'Alice', '_AgeAtApplicationYears' => '33', 'phone' => '111-111-1111', 'state' => 'HI', 'zip' => '11111', 'userName' => 'testUser', 'lastName' => 'Firstimer', 'address' => '111 test street' } };

To access e.g. the 'state' attribute, use $xml->{LOGIN}->{state}

Hope this helps, -gjb-

Update: What you call 'embedded tags' are actually termed attributes in XML speak ;)


Comment on Re: XML package for parsing values in the opening tag.
Select or Download Code
Replies are listed 'Best First'.
Re: Re: XML package for parsing values in the opening tag.
by dwatson06 (Friar) on Apr 14, 2004 at 14:30 UTC
    It's a parse of sheer beauty.
    Works perfectly.

    Thank you very much,
    DWW

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://345059]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (17)
As of 2015-07-31 20:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (281 votes), past polls