Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Yes, after inserting print Dumper $XML_1, i got the ojbect, but why i can't print $ref?

My really intention is to parse the result of get request and print the result i wanted into a .csv file.
#!/usr/bin/perl use XML::Smart; use Data::Dumper; use warnings; use strict; my @array = (); my %data = (); open OUTFILE, '>result2.csv' or die $!; open FILE, 'fund.txt' or die $!; while (<FILE>) { chomp; my $XML = XML::Smart->new("http://cmsbeta.morningstar.com/api/v2 +/2008428323/securities/$_"."/documents?colids=590&fields=*"); print Dumper $XML; eval{ %data = %{$XML->{Document}->{Content}->{People}}; }; for my $li (keys %data){ print "$li:$data{$li}"."\n"; push (@array,$data{$li}); } print OUTFILE ("$_,","@array"."\n"); @array = (); } close(OUTFILE); close(FILE); exit;
the result i got is
C:\Users\rchen4\Desktop\Perl_XML>perl parse_prepare.pl Use of uninitialized value $data in pattern match (m//) at C:/Dwimperl +/perl/site /lib/XML/Smart/Tree.pm line 169, <FILE> line 1. $VAR1 = bless( do{\(my $o = bless( { 'tree' => {}, 'a' => [], 'TIEONUSE' => { 'h' => 'XML::Smart::Tie::Has +h', 'a' => 'XML::Smart::Tie::Arr +ay' }, 'parser' => '', 's' => \sub { "DUMMY" }, 'c' => sub { "DUMMY" }, 'point' => ${$VAR1}->{'tree'}, 'h' => {}, 'g' => \*Object::MultiType::Saver::NULL, 'b' => \sub { "DUMMY" } }, 'Object::MultiType::Saver' ))}, 'XML::Smart +' );
I still got nowhere.I can use XML::Simple to finish the similar task, but i think XML::Smart is more cool so i want to try it.

In reply to Re^2: Why XML::Smart module can't work by sanguine_perl
in thread Why XML::Smart module can't work by sanguine_perl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-24 22:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found