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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl XML Question 1

Status
Not open for further replies.

zelizelizelizeli

Technical User
Sep 13, 2006
4
US
I am trying to get the value in between to tags:
I am trying to get whats inside <me> </me> which is the 34343434 but cannot.

xml.xml
-------
<main>
<new>
<me nam="ge">34343434</me>
</new>
</main>


xml.pl
------
#!/usr/bin/perl
use XML::Simple;
use Data::Dumper;
$xml = new XML::Simple;

$data = $xml->XMLin("result2.xml");

$name=$data->{new}->{me}->{nam};
$id=$data->{new}->{me};
print "This is the nam=$name\n";
print "$id\n";

I cannot get $id.

Can anyone help.
 
>$id=$data->{new}->{me};
Do this instead.
[tt]$id=$data->{new}->{me}[blue]->{content}[/blue];[/tt]
 
Thank you so much for the answer.

I didn't know that {content} is a set variable that can be used.

Eeneh!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top